![]() ![]() | Attempting repeated inheritance in C++. | Lecture 4 - slide 17 : 24 Program 1 |
#include <iostream> #include <string> using namespace std; class A { public: int a; A(int a): a(a){} }; class D : public A, public A { // error: duplicate base type A invalid public: int d; D(): d(9){} }; int f(D &x){ // problem: how should we select one or the other A branch? cout << x.d << endl; } int main(){ D d; f(d); }