C++ C++;覆盖运算符<&书信电报;在继承类中

C++ C++;覆盖运算符<&书信电报;在继承类中,c++,stream,operator-overloading,C++,Stream,Operator Overloading,我有一个基类,其中重写很容易!您需要调用接受Abonne的版本。所以简单地说: return out << static_cast<const Abonne&>(etudiant) << " ... and more" << endl; // ^^^^^^^^^^^^^^^^^^^^^^^^^^ return out“我有一个基类,它包含可以与类限定符一起使用的Create aput()函数的重写。谢谢:)您知道不强

我有一个基类,其中重写很容易!您需要调用接受
Abonne
的版本。所以简单地说:

return out << static_cast<const Abonne&>(etudiant) << " ... and more" << endl;
//            ^^^^^^^^^^^^^^^^^^^^^^^^^^

return out“我有一个基类,它包含可以与类限定符一起使用的Create a
put()
函数的重写。谢谢:)您知道不强制转换的另一种方法吗?Abonne::operator您知道在函数不是全局函数的情况下是否可以吗?@BlueWizard:它会。
    friend ostream& operator<<(ostream& out, const Dog& dog);

ostream& operator<<(ostream& out, const Dog& dog)
{
    return out << dog << endl;
}
return out << static_cast<const Abonne&>(etudiant) << " ... and more" << endl;
//            ^^^^^^^^^^^^^^^^^^^^^^^^^^