I have 2 classes, Edge and Point. Edge contains Point P1 and Point P2 as private memebers. Edge has accessor functions
Point getP1()
{
return P1;
}
and the same for P2.
Point has << overloaded -
ostream & operator << (ostream &output, Point &p);
I am trying to overload << for Edge:
ostream & operator << (ostream &output, Edge &e);
this works fine:
ostream & operator << (ostream &output, Edge &e)
{
Point x = e.getP1();
Point y = e.getP2();
output << "P1: " << x << " P2: " << y;
return output;
}
but this doesn't work:
ostream & operator << (ostream &output, Edge &e)
{
output << e.getP1() << " " << e.getP2();
return output;
}
The compiler says "Error: no match for operator << in output << Edge::getP1()()"
First, why are there two sets of parentheses in the compilers message?
Second, why does this happen?
Thanks!
Dave