+ 1
Why can a subclass inherit the fields, methods, properties and indexers from the superclass, but not the constructors?
?!🤔
2 Respuestas
+ 5
normally a subclass adds attributes.
Those new attributes are initialized by the constructor.
+ 1
Because you're creating a completely different object. The way you construct one will more than likely not be the way you construct the other. How would the superclass's constructor know about the new properties you created in the subclass? It can't, so that's why you use the superclass's constructor to initialize the properties that it has, and then you use the constructor of the subclass to initialize the properties that it has.