Program of function overloading:
class vector{
private :
int v[3];
public:
/*friend istream & operator >> (istream & ,vector &);*/ //overloading the
//insertion operator
// for the vector type object
friend vector operator * (vector,int);
friend vector operator * (int ,vector);
vector() dummy constructor
{
}
vector (int *p);
void show();
}; // class termination
/* istream & operator >>(istrream &din ,vector & b )
for( int i=0;i<3;i++)
din >> b.v[i];
return din;//for cascading
}*/
vector operator *(vector a,int b)//function overloading
{ vector c;
for(int i=0;i<3;i++)
c.v[i]=b*a.v[i];
return c;
vector operator *(int a,vector b)
vector c;
c.v[i]=a*b.v[i];
vector:: vector( int *p)
v[i]=p[i];
void vector ::show()
for (int i=0;i<3;i++)
cout << "\n"<
void main()
int t[]={ 1,2,3};
vector a,b(t),c;
clrscr();
a=b*10;
c=20*b;
b.show();
a.show();
c.show();
getch();