A
AalaarDB
struct base
{
int x, y, z;
base() {x = 0; y = 0; z = 0;};
base(int x1, int y1, int z1) {x = x1; y = y1; z = z1;};
};
struct intermediate1 : public virtual base {};
struct intermediate2 : public virtual base
{
intermediate2() : base(1,2,3) {};
};
struct derived : public virtual intermediate2, public virtual
intermediate1
{
derived() : intermediate2() {};
};
int main()
{
derived temp;
return 0;
}
OK, I know that classes don't actually inherit constructors. But it
sure seems like derived is inheriting something it shouldn't. When I
step through derived's instantiation I see that derived calls base's
default ctor and then calls intermediate2's ctor which does NOT call
base's custom ctor (I guess since it's already ctored). What I want
is derived to call intermediate2 to call base custom ctor. Why does
it do this, and how can I do what I want?
{
int x, y, z;
base() {x = 0; y = 0; z = 0;};
base(int x1, int y1, int z1) {x = x1; y = y1; z = z1;};
};
struct intermediate1 : public virtual base {};
struct intermediate2 : public virtual base
{
intermediate2() : base(1,2,3) {};
};
struct derived : public virtual intermediate2, public virtual
intermediate1
{
derived() : intermediate2() {};
};
int main()
{
derived temp;
return 0;
}
OK, I know that classes don't actually inherit constructors. But it
sure seems like derived is inheriting something it shouldn't. When I
step through derived's instantiation I see that derived calls base's
default ctor and then calls intermediate2's ctor which does NOT call
base's custom ctor (I guess since it's already ctored). What I want
is derived to call intermediate2 to call base custom ctor. Why does
it do this, and how can I do what I want?