📜  c++ 访问父类函数 - C++ 代码示例

📅  最后修改于: 2022-03-11 14:44:54.924000             🧑  作者: Mango

代码示例1
class left {
public:
    void foo();
};

class right {
public:
    void foo();
};

class bottom : public left, public right {
public:
    void foo()
    {
        //base::foo();// ambiguous
        left::foo();
        right::foo();

        // and when foo() is not called for 'this':
        bottom b;
        b.left::foo();  // calls b.foo() from 'left'
        b.right::foo();  // call b.foo() from 'right'
    }
};