Jer*_*oen 3 d reference ownership copy-assignment
当我在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?)
}
}
Run Code Online (Sandbox Code Playgroud)
仅复制引用,对象本身不重复.您可以使用.dup
虽然显式复制对象.
归档时间: |
|
查看次数: |
313 次 |
最近记录: |