3
class Parent
{
...
friend ostream& operator<<(ostream&, const Parent&);
};
class Child : public Parent
{
...
friend ostream& operator<<(ostream&, const Child&);
};
ostream& operator<< (ostream& os, const Parent& p)
{
os << ... ;
return os;
}
ostream& operator<< (ostream& os, const Child& c)
{
os << c.Parent << ... ; // can't I access the subobject on this way?
return os;
}
Как я могу назвать оператора родителя внутри оператора Child? Это просто дает мне ошибку «недопустимое использование Parent :: Parent»Доступ анонимный Субъект C++ (cout)
'ОС << static_cast (с)' –
@PiotrS. Сделайте это ответом. –