Invoking constructor of derived class execute before constructor of base class

后端 未结 3 973
无人共我
无人共我 2021-01-03 04:20

Well, originally I had a couple of constants (like MAX_SPEED) with different values in every of the derived classes. The idea was to use those values in some methods of the

3条回答
  •  庸人自扰
    2021-01-03 04:48

    One more option is to make child class constructor as static , so that it executes first than parent class constructor. but it not preferable it violates the oop design

提交回复
热议问题