How a class can know the current reference of itself?
Pippo via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Aug 4 03:31:10 PDT 2017
On Friday, 4 August 2017 at 09:58:34 UTC, Mike Parker wrote:
>
> Your first error is actually this line:
>
> callToMyFunction(ref this);
>
> You can't use ref in a function call, only in function
> declarations. But once that's fixed, you've got other errors in
> the code you've posted -- you've declared main to return int,
> but you return nothing; you're using writefln without importing
> it.
>
> Also, class references are *already* references, so you don't
> need to declare the function parameters as ref. Finally,
> although this is not an error, @property has no effect on
> member variables. It only applies to member functions. Also,
> you never assign a value to myProperty, so even when the errors
> are fixed nothing is printed.
Perfect. I've missed some details (return from main and import
std.stdio for example) to expose my problem :D
My mistake was the inappropriate use of "ref".
Thank you! :)
More information about the Digitalmars-d-learn
mailing list