how to copy SubClass object in BaseClass copy constructor

前端 未结 3 699
清歌不尽
清歌不尽 2021-01-28 10:53

I would like to make copy of SubClass object in BaseClass constructor. I need that the following code execute correctly.

class BaseClass{
    BaseClass() {}
             


        
3条回答
  •  不思量自难忘°
    2021-01-28 11:31

    You seems to be having a design upside-down. If you need to do what you are asking then you need to re-think over your design. Ideally in your subclass constructor, you should be copying or initializing the base class properties by calling super().

提交回复
热议问题