I'm having trouble with C++ classes and inheritance right now...
Let's say we have
Class A {
A(string name);
~A();
void func(void);
}
Class B : public A {
B(string name);
~B();
...
}
Class C : public A {
C(string name);
~C();
...
}
Class D : public B, public D {
D(string name);
~D();
...
}
Whenever I create D, it calls the constructor for B and the one for C which results in multiple instances of A. The compiler then says it doesn't know which "func" it should call, the one from B or the one from C.
I would like to know how to call A constructor ONLY ONCE and then use it to build B and C.
I already tried using B::func() to be able to call func() but has I must have a cout in the class A builder. It results in wrong output.