I have two structs:
struct Vertex
{
int row;
int col;
friend istream & operator >>(istream & is, Vertex & v)
{
char t[3];
is >> t;
v.col = t[0] - 'A';
v.row = t[1] - '0';
return is;
}
};
struct Move
{
Vertex orig;
Vertex dest;
};
That compiles without error.
Now however I'd like to overload >> for Move like this:
friend istream & operator >> (istream & is, Move & m)
{
is >> m.orig;
is >> m.dest;
return is;
}
That is, the >> for Move calls the >> for Vertex twice.
When I do that and try to compile my compiler throws an error message telling me that the >> operator isn't overloaded for Vertex eventhough the Vertex operator >> compiled fine before I added that version of the overloaded >> operator for Move.
Why doesn't the above version of >> for Move work?
Thanks.