D Classes Passed By Reference or Value?

Alex Parrill via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Aug 16 15:36:20 PDT 2015


On Sunday, 16 August 2015 at 22:31:02 UTC, Brandon Ragland wrote:
> ref MyClass doStuff(){
> MyClass mc = new MyClass() // Heap allocation, using new....
> return mc;
> }
>

This attempts to return a reference to the _variable_ `mc`, not a 
reference to the class. Just remove `ref` from the function 
signature.


More information about the Digitalmars-d-learn mailing list