Assume one has a class derived from two base classes.
class Derived : public Base1, public Base2 {
};
In order to instantiate/construct an object of type Derived my initial idea was to use parameter pack. The problem is that I do not know how to dispatch arguments between Base1 and Base2 respectively.
template <typename... TArgs>
Derived(TArgs&&... args)
: Base1(/* what goes here? */)
, Base2(/* what goes here? */) {
}
I know in advance that Derived inherits from only two base classes. My question is whether one has a way construct derived with a syntax similar to the below?
Derived d({arguments for Base1}, {arguments for Base2});
template <typename T1, typename T2>
Derived : Base1(T1), Base2(T2) {}
And if possible then what would be the requirements for the Base classes?
How should they accept they construction arguments?
Aucun commentaire:
Enregistrer un commentaire