【发布时间】:2013-11-29 21:19:37
【问题描述】:
当我在D中分配一个对象时,它会被复制吗?
void main() {
auto test = new Test(new Object());
tset.obj;
}
class Test {
public Object obj;
public this(Object ref origObj) {
obj = origObj; // Will this copy origObj into obj, or will origObj and obj point to the same data? (Is this a valid way to pass ownership without copying the object?)
}
}
【问题讨论】:
标签: reference d ownership copy-assignment