Im trying to overload the operator <<
const ostream & operator<<(const ostream& out, const animal& rhs){
out << rhs.a;
return out;
}
it seems im getting an error because im returns a constant, and also because the first argument is const refrence for the ostream object.
cout << objectOfAnimal1 << objectOfAnimal2 ;
It works fine if I change the return type and the operator signature to this:
ostream & operator<<(ostream& out, const animal& rhs)
source
share