문제

if I do:

myclass a = new myclass();
myclass b = a;

Does b points to or is a copy of a?

도움이 되었습니까?

해결책

Classes in D use reference semantics so b points to the same object as a. structs, on the other hand, use value semantics so...

auto a = mystruct();
auto b = a;

...would refer to distinct objects.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top