使用new复制当前类
Making a copy of the current class using new
如何使用new复制当前类?我试过
Sample* pointerToSample = new this;
有人能解释一下我该怎么做吗?
使用复制构造函数,快速搜索给出了本教程:https://www.tutorialspoint.com/cplusplus/cpp_copy_constructor.htm
相关文章:
- C++17复制构造函数,在std::unordereded_map上进行深度复制
- 在C++程序中输入的文本文件将不起作用,除非文本被复制和粘贴
- 使用strcpy将char数组的元素复制到另一个数组
- 是否可以初始化不可复制类型的成员变量(或基类)
- 为什么在C++中使用私有复制构造函数与删除复制构造函数
- C++ Windows 驱动程序MSB3030无法复制该文件,因为它找不到
- 复制列表初始化的隐式转换的等级是多少
- 当从函数参数中的临时值调用复制构造函数时
- 有可能在Armadillo中复制MATLAB circshift方法吗
- 复制几乎为空的数组的最快方法
- 如果"new int"返回"int*",那么为什么"new int[n]"不返回"int**"?
- 以下示例中如何避免代码复制?C++/库达
- 有没有一种方法可以使用placement new将堆叠对象分配给分配的内存
- 使用复制构造函数初始化 new[]
- 正在使用放置-new,复制存储,然后访问值未定义的行为
- 使用new复制当前类
- 使用 "new" 复制构造函数调用
- 如何在不复制的情况下取消引用使用 New 创建的指针
- 使用new操作符在不知道对象类型的情况下将其复制到堆中
- 放置new以避免复制构造函数