Difficulty with operator overloading opMulAssign

Jarrett Billingsley kb3ctd2 at yahoo.com
Sun Mar 2 17:29:48 PST 2008


"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;

:) 




More information about the Digitalmars-d-learn mailing list