How one can overload an operator<< for a nested private class like this one?
class outer {
private:
class nested {
friend ostream& operator<<(ostream& os, const nested& a);
};
// ...
};
When trying outside of outer class compiler complains about privacy:
error: ‘class outer::nested’ is private
const
member function. If it isstd::ostream& print(std::ostream &out) const
, thenoperator<<
can be just one line :return obj.print(dest);
. – Senhorita