With virtual inheritance, the most derived class should call virtual base constructor, so:
struct D : C<B> // D: ThermostatedRotorJobQueueFactoryStub
{
D(const X& x, const Y& y) : A(this), C(this, x, y) { cout << "D constructor" << endl; }
};
But that is also true for C<B>
:
template <>
struct C<B> : B
{
template <typename... Args>
C(Args&&... args) : A(this), B(std::forward<Args>(args)...) {
cout << "C constructor" << endl;
}
};
1
solved Virtual inheritance and default constructor