I decided to use template inheritance to avoid multiple and virtual inheritance. My goal is to make different children (4 or 5 generations or inheritance, which I do not control) have a common function call no matter what they receive.
My solution inserts template inheritance like this:
template <typename BASE> class common_call : public BASE { public: void foo() { } }; class child1 : public common_call <base1> {}; class child2 : public common_call <base2> {};
There is a problem calling the base constructor. The base1 and base2 classes (not written by me) have different constructors that I have to call in the initialization list. The common_call pattern knows nothing about these constructors, but child classes do as they are currently directly inherited.
Do I have a way to do this:
class child3 : public common_call<base3>{ public: child3(param1, param2) : base3(param2) {} };
I try to avoid creating specialized specialized templates for each type of database, if possible.
source share