small example of how this can be done properly
Code:
#include<iostream>
using namespace std;
class Point
{
int x;
int y;
public:
Point(int X,int Y) : x(X),y(Y) {}
friend ostream& operator << (ostream&,const Point&);
};
ostream& operator << (ostream& os,const Point& p)
{
os<<"( "<< p.x << "," << p.y << " )";
return os; // enables cascading as above
}
int main()
{
Point p(10,20);
cout<<p<<endl;
return 0;
}
This is the way usually taught in books. When you have digested this then read this to see an even better way of doing it.