I have a classical virtual inheritance diamond:
class A {
protected:
A(const char *x) { ... }
}
class B: public virtual A {
protected:
B(): A(NULL) { ... }
public:
virtual void foo() = 0;
}
class C: public virtual A {
protected:
C(): A(NULL) { ... }
public:
virtual void bar() = 0;
}
class D: public B, public C {
public:
D(const char *x): A(x) { ... }
void foo();
void bar();
}
I use NULL in B and C because as they’re abstract classes, the A ctor will never be called in their constructurs. Is there a nicer way to do it, otherwise than specify NULL in the constructor or declare parameterless constructor in A? I want the constructor to be called with a parameter, therefore the A() {} ctor should be allowed only in abstract classes.
I am closing this as the rigth answer probably does not exist. IMO the best workaround is the