0

I have searched for a similar question but found none. So I am sorry if a duplicate will occur because this looks like a common problem to me.

My question is very simple, consider the following:

class A {
public:
  virtual void doit();
};

class B1 : public virtual A {
public:
 void doit();
};

class B2 : public virtual A {
public:
 void doit();
};

class C : public B1, public B2 {};

What happens if I do:

int main(int argc, char** argv) {
  C* el = new C();
  el->doit(); /* WHAT HAPPENS? */
}

Because the last class does not override the method, so it takes the method from parents... but which one does it select?

Andry
  • 16,172
  • 27
  • 138
  • 246

0 Answers0