QuesHub > 函数 > 对象 > 这是 > ASK DETAIL

Why constructor can not be inherited?

Sophia Taylor | 2023-05-05 12:30:36 | page views:1781
I'll answer
Earn 20 gold coins for an accepted answer.20 Earn 20 gold coins for an accepted answer.
40more

Amelia Thomas

Studied at the University of Vienna, Lives in Vienna, Austria.
This is one reason constructors aren't inherited. Inheritance means a derived object can use a base-class method, but, in the case of constructors, the object doesn't exist until after the constructor has done its work. I understand the constructor is called before object construction is completed.
2023-05-13 12:30:36

Julian Patel

QuesHub.com delivers expert answers and knowledge to you.
This is one reason constructors aren't inherited. Inheritance means a derived object can use a base-class method, but, in the case of constructors, the object doesn't exist until after the constructor has done its work. I understand the constructor is called before object construction is completed.
ask:3,asku:1,askr:137,askz:21,askd:152,RedisW:0askR:3,askD:0 mz:hit,askU:0,askT:0askA:4