Alex for the quiz problem I neglected to write the "const" in these lines:
1 2 |
string getName() const { return m_name; } string getColor() const { return m_color; } |
and compiler refused to compile my program. I think this is because we wrote for example
1 |
const Apple& a |
in the header of our operator<<-overloading-functions and thus when we used a.getName() compiler could not guarantee that the object will survive unchanged in getName() function so did not do the job… . Am I right? (Sorry for poor English)