【发布时间】:2020-11-24 06:36:31
【问题描述】:
我正在处理运算符重载和继承。我目前有类似于以下代码的内容:
istream& operator >> (istream& in, derived& d)
{
/* Some code asking for input to populate the object's data members*/
cin >> d; /*Here, the operator called is this one, creating an infinite loop*/
}
基类有一个 istream >> 操作符,当试图调用它时,操作符实际上调用了它自己,导致了一个循环。如何从派生的访问基地的运营商?
【问题讨论】:
标签: c++ inheritance operator-overloading iostream friend