Copy constructor needs to call a method that depends on the object, but constructor can't be virtual

后端 未结 6 687
伪装坚强ぢ
伪装坚强ぢ 2021-01-20 19:24

I have an abstract base class with two inherited classes. In both these classes I define a virtual method that is used by the constructor. Now I need to create a copy constr

6条回答
  •  青春惊慌失措
    2021-01-20 20:22

    Create a virtual method in the object that's passed as an argument to the copy constructor, and call it from the copy constructor. Pass 'this' to that method if necessary.

提交回复
热议问题