What should opAssign return?
Nathan Reed
nathaniel.reed at gmail.com
Mon Oct 22 23:23:22 PDT 2007
Charles D Hixson wrote:
> What I would expect is:
>
> class A
> {
> A opAssign(A a)
> {
> // do stuff here
> return this;
> }
> }
>
> but the only examples that I can find (variant.d) return *this ... which
> leaves me quite confused. Is this something special that Variant is
> doing to allow it to handle multiple types (I didn't follow the
> internals), or do I have what is supposed to be returned wrong?
'this' is a pointer to the object, so '*this' is (a reference to) the
actual object.
Thanks,
Nathan Reed
More information about the Digitalmars-d-learn
mailing list