In C++11, what is meant by inheriting the constructor? If it is what i think it is (Base class constructor is brought in the scope of the derived class), what are its implications on my code? What are the applications of such a feature?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Inheriting Constructors means just that. A derived class can implicitly inherit constructors from its base class(es).
The syntax is as follows:
So now D has the following constructors implicitly defined:
Ds members are default constructed by these inherited constructors.
It is as though the constructors were defined as follows:
The feature isn’t anything special. It is just a shorthand to save typing boilerplate code.
Here are the gory details: