Program of cascading:
class vector{
private :
int v[3];
public:
friend istream & operator >> (istream & ,vector &);//overloading the
//insertion operator
// for the vector type object
friend ostream & operator << (ostream & ,vector &);
friend vector operator * (vector,int);
friend vector operator * (int ,vector);
void show();
}; // class termination
istream & operator >>(istream &din ,vector & b )
{
for( int i=0;i<3;i++)
{
cout<<"enter "<
din >> b.v[i];
}
return din;//for cascading
}
ostream & operator <<(ostream &dout ,vector & b )
{
for( int i=0;i<3;i++)
{
dout << b.v[i]<<"\n";
}
return dout; //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;
for(int i=0;i<3;i++)
c.v[i]=a*b.v[i];
return c;
}
void vector ::show()
{
for (int i=0;i<3;i++)
cout << "\n"<
}
void main()
{
vector a,b,c;
clrscr();
cin>>b;//calling function cin is 1st argument and b other
cout << b;
a=b*10;
c=20*b;
/* b.show();
a.show();
c.show();*/
cout<
cout<
getch();
}