Difficulty with operator overloading opMulAssign

Spacen Jasset spacenjasset at yahoo.co.uk
Mon Mar 3 02:29:40 PST 2008


Jarrett Billingsley wrote:
> "Spacen Jasset" <spacen at yahoo.co.uk> wrote in message 
> news:fqfi8l$haj$1 at digitalmars.com...
>> DMD 1 reports an error for the struct below, marked "// Error":
>>
>> math/vector.d(35): Error: incompatible types for ((this) *= cast(float)1
>> / m)): 'Vector3 *' and 'float'
>> math/vector.d(35): Error: 'this' is not of arithmetic type, it is a
>> Vector3 *
>>
>> What is it that I am doing wrong here?
>> ...
>> void normalise()
>> {
>> float m = magnitude();
>> if (m) {
>> this *= 1 / m; // Error
>> }
>> }
> 
> Try
> 
> (*this) *= 1 / m;
> 
> :) 
> 
> 
That's something I didn't try but should of. I didn't think 'this' was a 
pointer type proper. Thanks for the fix :-)


More information about the Digitalmars-d-learn mailing list