Point p1(0,3);
Point p2; //this is the default constructor
cout << p2.getX() << “ “ << p2.getY() << endl;
//result is `0 0`
cout << p1 << endl; //operator overloading of <<
//result is `X:0 Y:3`;
cout << p1 - p2<<endl; //operator overloading, - gives the distance
how can I use operator overloading in this situation?



LinkBack URL
About LinkBacks



). A distance member function could be useful for finding the distance a point is from the origin, however.