You are here:

C++/constructors in c++

Advertisement


Question
Hi sir !why can't we inherit constructors in c++?
i have read so many books.but i can not understand.
can you please explain clearly?

Answer
Hello,
I think this is because constructors are specific to a given class.
A constructor is a way of initializing variables specific to a given class. That means it is
not a function and hence can't return a type. Now, if you inherit it, the
subclass has to have all the variables as well which  is not allowed in C++  

C++

All Answers


Answers by Expert:


Ask Experts

Volunteer


henry

Expertise

I can confidently answer any question both basic and advanced in C++. Areas like templates, algorithms, Gui and design patterns are of interest to me. i will not answer questions about web programming.

Experience

I have a 3- year- work experience in software Engineering.

Education/Credentials
I am a bachelor of Engineering graduate

©2016 About.com. All rights reserved.