C ++中成员函数的歧义访问?

时间:2011-07-25 05:04:58

标签: visual-c++

class base1
{
public:
void display()
{
    cout<<"Base1"<<endl;
}
};
class base2
{public:
void display()
{
    cout<<"Base2"<<endl;
}};
class derived :public base1, public base2
{
};

任何人都可以解释如何通过派生类对象调用base :: display()。

2 个答案:

答案 0 :(得分:0)

我相信你会这样做:

this->base1::display(); // call the display() method as defined in base1

this->base2::display(); // call the display() method as defined in base2

答案 1 :(得分:0)

derived d;
d.base1::display();