Copy instead of reference?

Namespace rswhite4 at googlemail.com
Thu May 23 04:40:51 PDT 2013


To be more detailed:

I'd expected that the code with 'getA' without ref

[code]
	A getA() {
		writeln("Return A");
		return this._a;
	}
[/code]

would print this output:

----
CTor 42
opAssign R 42
DTor 42
Return A
Postblit 42
opAssign R 84
DTor 84
DTor 42
----

And with 'getA' with ref

[code]
	ref A getA() {
		writeln("Return A");
		return this._a;
	}
[/code]

would print this output:

----
CTor 42
opAssign R 42
DTor 42
Return A
opAssign L 42
DTor 42
DTor 42
----


More information about the Digitalmars-d-learn mailing list