C++ derived class member is ambiguous

31 views Asked by At

I have 3 classes, A, B, C.

A and B both have a protected member, let's call it x. It's a pointer.

C inherits from both A and B.

Question: Does C have its own copy of x now? If not, what does x mean now, B::x or A::x? How can C access its own x?

Btw, A and B are actually created using a template class so C looks like this:

class C : public A<someType>, public B<otherType> { 
   public:
      void metod() {
         this->x = 1 // doesn't work because now the member is ambiguous.
      }
}
0

There are 0 answers