What should opAssign return?

BCS ao at pathlink.com
Tue Oct 23 08:18:17 PDT 2007


Reply to Rioshin an'Harthen,

> class A
> {
> A opAssign(A a)
> {
> return this;
> }
> }
> the return statement is trying to return a pointer to A, when the
> method signature says to return an A. Thus the dereferencing in
> variant.d, so that the return statement returns *this instead.
> 

fails: the type A is already a pointer to an object (because it is a class) 
so the type of "this" is "A" not "A*".




More information about the Digitalmars-d-learn mailing list