Quick, Beginner C++ Overloading Question - Getting the compiler to perceive << is defined for a spec
- by Francisco P.
Hello everyone.
I edited a post of mine so I coul
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.