I am trying to overload the insertion operator for a class called resident. Whenever I run this, res.m_name does not out put unless I add an endl after res.m_name. This function is a friend function of resident.
1 2 3 4 5 6 7 8 9 10 11 12
ostream& operator<<(ostream& os, const resident& res)
{
os << res.m_name
<< (res.m_is_alive == true ? " is alive " : " is dead ")
<< "with hair color " << res.m_hairColor
<< " and is"
<< (res.m_is_murderer == true ? " " : " not ")
<< "the murderer." << endl;
return os;
}