I have resolved diamond inheritance with changing inheritance to virtual.
Unfortunately it breaks my constructor. Diamond inheritance is issue in other case.
One side of the diamond:
TModuleBase -> TServerModuleBase -> MyModule
MyClass inherits base class
class MyModule : public TServerModuleBase { ... } MyModule::MyModule() : TServerModuleBase(ModuleName()) { } QString MyModule::ModuleName(void) { return "MyModuleName"; } Since TModuleBase and TServerMosuleBase have two possible constructors (difference: Servers are not public but protected):
class TModuleBase { public: explicit TModuleBase(void); explicit TModuleBase(QString moduleName); } class TServerModuleBase : public virtual TModuleBase { protected: explicit TServerModuleBase(void); explicit TServerModuleBase(QString moduleName); } TServerModuleBase::TServerModuleBase(void) : TModuleBase() { } TServerModuleBase::TServerModuleBase(QString moduleName) : TModuleBase(moduleName) { } When MyModule constructors is called it calls invalid constructor:
TServerModuleBase(ModuleName()) //expected TServerModuleBase() //called When I changeback
class TServerModuleBase : public virtual TModuleBase into:
class TServerModuleBase : public TModuleBase constructor selection works as expected.
I am using g++. And yes, I did clean build. Many times.
Thx for your attention, time and help.