class A { protected: string word; }; class B { protected: string word; }; class Derived: public A, public B { };
How would the accessibility of the variable word be affected in Derived? How would I resolve it?
word
Derived
It will be ambiguous, and you'll get a compilation error saying that.
You'll need to use the right scope to use it:
class Derived: public A, public B { Derived() { A::word = "A!"; B::word = "B!!"; } };
1.4m articles
1.4m replys
5 comments
57.0k users