Object as function argument
Chris Sperandio via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu Mar 5 11:35:34 PST 2015
Hi,
I'm a developer coming from C and I've a question about class
instance as method or function parameter.
In the book "The D Programming Language", I read the instance was
passed by reference to functions (in the opposite of structures).
I understood that it was the same object in the function and the
caller. But I'm think, I was wrong because when I print the
addresses of an object before the function call and inside the
function, they're not the same but the changes from the function
are kept in the instance.
If I use the "ref" qualifier in the function declaration, the 2
addresses are the same.
How do the changes work in the function? Is there a copy ? Or a
"magic" trick :) ?
Chris
More information about the Digitalmars-d-learn
mailing list