更新时间:2023-02-02 23:29:20
怎么样
if (obj.parent != NULL) parent = new City(*obj.parent) else parent = NULL;
这应该有效,除非您在父层次结构中有循环。
This should work unless you have cycles in the parent hierarchy.
复制在C ++中具有自指针的类的构造函数?
复制具有C ++中没有默认构造函数的成员的类的构造函数