I posted a while back about how to overload <<
It seems all the examples online have the second argument as const, ie
ostream & operator << (ostream &output, const Point &p); but if I have a member function that simply returns a double
double Point::getX()
{
return x_;
} In the << function it complains about the const
error: the object has cv-qualifiers that are not compatible with the member function
object type is: const Point So I've fixed it two ways:
1) make the getX() function return a const double
2) change the << function to not accept a const, ie
ostream & operator << (ostream &output, const Point &p); So should accessor functions always return const? Or is it ok to remove const from the << definition?
Thanks!
Dave