operator overloading for streams
Hi,
This one's not so important but, nice to have. I've been playing with the operator overloading for some simple classes and it's quite nice. I found some examples of overloading << which don't work for me though.
I use this in the header file:
Code:
ostream& operator <<(ostream&, const Point2D&);
// the actual operator
ostream & Point2D::operator <<(ostream &os, const & Point2D point) {
return os << point.x << "," << point.y << endl;
}
I get some compiler error complaining about too many parameters. Although every example I've seen takes two parameters. I get actually get it to compile with only the ostream parameter but it doesn't do anything for me...