【发布时间】:2016-02-21 13:37:33
【问题描述】:
我有一个基类,其中覆盖了
friend std::ostream& operator<<(std::ostream& out, const Animal& animal);
ostream & operator<<(ostream & out, const Animal& animal)
{
out << animal.age << "," << animal.size << endl;
}
这是在我的 Abonne 类的 .h 中。我有一个名为 Etudiant 的 Abonne 类的继承类。我希望再次覆盖 Etudiant 类中的
friend ostream& operator<<(ostream& out, const Dog& dog);
ostream& operator<<(ostream& out, const Dog& dog)
{
return out << dog << endl;
}
它不起作用,调用自身的
我应该如何进行?
谢谢。
【问题讨论】:
-
“我有一个基类,其中包含对 关于此语句的所有内容都是错误的。
-
创建一个可与类限定符一起使用的
put()函数。
标签: c++ stream operator-overloading