Q:

operator overloading<< error

Im trying to overload the operator<< 
const ostream & operator<<(const ostream& out, const animal& rhs){
    out << rhs.a;
    return out;
}

it seems that im getting an error because im return a const and also because the first argument is const refrence to an ostream object.
cout << objectOfAnimal1 << objectOfAnimal2 ;

it work just fine if I change the the return type and the operator signature to this one:
ostream & operator<<(ostream& out, const animal& rhs)

A:

You need to have:    
ostream & operator<<(ostream& out, const animal& rhs)

In your code You are trying to modify a const ostream object, and so you get the errors.
It should not be const.

