inheritance
why constructor does not inherit in .net with example
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Anil KumarPosted Mar 3, 2015, 1:28 PM
- When you create the instance of the derived class, it automatically calls the constructor (one without parameter) of the base class.
Now to answer your question :- Constructors are not inherited because we wouldn't be able to properly determine how our derived class objects were instantiated. When all derived classes would use parent's constructors implicitly, in my opinion it would be a problem because if we forgot to redefine constructor, the object might have been initialized incorrectly
Please mark the answer as Accepted if it solves the purpose