Hello everyone.
I edited a post of mine with this question, yet got no answers.
I overloaded << for a class, Score
(defined in score.h), in score.cpp.
ostream& operator<< (ostream & os, const Score & right)
{
os << right.getPoints() << " " << right.scoreGetName();
return os;
}
(getPoints
fetches an int
attribute, getName
a string
one)
I get this compiling error for a test in main(), contained in main.cpp
binary '<<' : no operator found which takes a right-hand operand of type 'Score' (or there is no acceptable conversion)
How come the compiler doesn't 'recognize' that overload as valid? (includes are proper)
Thanks for your time.
EDIT:
As requested, code causing the error:
cout << ":::::\n" << jogador.getScore() << endl;
jogador
is a Player
object, which contains a Score
one. getScore
returns that attribute.