With your current version:
std::ostream& operator<<(std::ostream& out, const Memory& mem)
{
int curr(mem.get_current());
for (int i = 0; i <= curr; ++i)
{
return out << mem.mem_[i] << std::endl;
}
}
If curr == 0
, nothing ever gets returned. You need to always return out
:
std::ostream& operator<<(std::ostream& out, const Memory& mem)
{
int curr(mem.get_current());
for (int i = 0; i <= curr; ++i)
{
out << mem.mem_[i] << std::endl;
}
return out; // outside the loop, so it always gets returned!
}