Pointers, casting, SetGetWindowLong problem...

Frits van Bommel fvbommel at REMwOVExCAPSs.nl
Sat Mar 10 04:34:35 PST 2007


Chris Warwick wrote:
> "Jarrett Billingsley" <kb3ctd2 at yahoo.com> wrote in message 
> news:est9bb$1pac$1 at digitalmars.com...
>> Nope, it's assignable with opAssign.  There are restrictions, but it can 
>> be overloaded.
> 
> For objects? Wouldnt that make assigning to a null object imposible?
> 
> MyObj obj = obj2;
> 
> if opAssign is overloaded that will always be
> 
> null.opAssign(obj2);
> 
> wont it?

No, one of the restrictions Jarrett mentioned is that an overloaded 
opAssign is only invoked if the type of the value assigned is different 
from the type of the variable it's assigned to.
If they have the same type (or the assigned value is implicitly 
convertible to the type of the variable) the user-defined opAssign isn't 
used.


More information about the Digitalmars-d-learn mailing list