开发者

ambiguity access of memberfunctions in C++?

class base1
{
public:
void display()
{
    cout<<"Base1"<<endl;
}
};
class base2
{public:
void displ开发者_如何学Goay()
{
    cout<<"Base2"<<endl;
}};
class derived :public base1, public base2
{
};

Can anyone explain how to call base::display() through derived class object.


I believe you would do this:

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

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


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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜