Creating clone of an object not working with virtual base class

流过昼夜 提交于 2019-12-04 22:25:41

Well, your copy constructor does nothing, so your clone method does nothing in the way of copying.

See line Derived(const Derived&) {}

EDIT: if you add code to copy by assignment all members of Derived, it will become a shallow copy. If you also copy (by making a new instance) your instance of Something, it will become a deep copy.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!