[ad_1]
I haven’t been able to find an answer that relates specifically to my question. It’s a bit of a “strange” case in terms of what I’ve seen.
So I have a class Child2
that inherits from Child1
that in turn inherits from the Parent
. The Parent
doesn’t have a constructor.
Here is how I inherit:
Child1.h:
class Child1 : virtual public Parent
This is the function that I want to call from Child2
‘s constructor:
void Child1::foo(unsigned int i)
{
// ...
}
Child2
Child2::Child2() : Child1()
{
foo(10);
}
There are no functions called foo()
in Child2
so there shouldn’t be any ambiguity if I understand correctly.
However, I encounter this error:
Child2.cpp: In constructor ‘Child2::Child2()’:
Child2.cpp:12:28: error: type ‘Child1’ is not a direct base of ‘Child2’
Child2::Child2() : Child1()
Child1
‘s constructor is working, so I’ve left it out. I’m not certain if it is important in this case.
[ad_2]