#include <iostream>
using namespace std;
struct A {
A() { cout << "A "; }
};
struct B: A {
B() { cout << "B "; }
};
struct C: A {
C() { cout << "C "; }
};
struct D: C, B {
D() { cout << "D "; }
};
int main(){
D d;
}
The result is A C A B D. My understanding is that D inherits from C and B, and if an object "d" is created in D, then it also has the attributes from C and B. And since B and C both inherits from A, D should also inherit from A. Can someone explain the result please? My prediction is way off...