使用new复制当前类

Making a copy of the current class using new

本文关键字:复制 new 使用      更新时间:2023-10-16

如何使用new复制当前类?我试过

Sample* pointerToSample = new this;

有人能解释一下我该怎么做吗?

使用复制构造函数,快速搜索给出了本教程:https://www.tutorialspoint.com/cplusplus/cpp_copy_constructor.htm