c++ Multiple parents with same variable name

后端 未结 3 1760
旧时难觅i
旧时难觅i 2020-12-31 08:24
class A{
    protected:
    int var;
};

class B{
    protected:
    int var;
};

class C : public A, public B {};

What happens here? Do the variab

3条回答
  •  死守一世寂寞
    2020-12-31 09:08

    You can access them in class C by A::var and B::var respectively.

    Here is a link that covers the same problem.

提交回复
热议问题