While working with templates I ran into a need to make a base class constructors accessible from inherited classes for object creation to decrease copy/paste operations. I was thinking to do this through using keyword in same manner with functions case, but that not work.
class A { public: A(int val) {} }; class B : public A { }; class C : public A { public: C(const string &val) {} }; class D : public A { public: D(const string &val) {} using A::A; // g++ error: A::A names constructor }; void main() { B b(10); // Ok. (A::A constructor is not overlapped) C c(10); // error: no matching function to call to 'C::C(int)' } So my question: Is there any way to import a base class constructors after new ones in inherited class been declared?
Or there is only one alternative to declare new constructors and call a base ones from initializer list?