c ++ dziedziczenie wirtualne
Problem:
class Base {
public:
Base(Base* pParent);
/* implements basic stuff */
};
class A : virtual public Base {
public:
A(A* pParent) : Base(pParent) {}
/* ... */
};
class B : virtual public Base {
public:
B(B* pParent) : Base(pParent) {}
/* ... */
};
class C : public A, public B {
public:
C(C* pParent) : A(pParent), B(pParent) {} // - Compilation error here
/* ... */
};
W podanej pozycji gcc skarży się, że nie może dopasować wywołania funkcji do Base (), czyli domyślnego konstruktora. Ale C nie dziedziczy bezpośrednio z Base, tylko przez A i B. Więc dlaczego gcc narzeka tutaj?
Pomysły? TIA / Rob