stuck on opDiv / opBinary

Spacen Jasset via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Aug 30 10:02:56 PDT 2015


I have just added an opDiv to this class, but it doesn't seem to 
pick it up.
math/vector.d(30): Error: 'this /= mag' is not a scalar, it is a 
Vector3

I can't see why that is, becuase my opMul works in the same 
place. Can anyone point out what I have done wrong?

Class Matrix {

     void normalise()
     {
         const float mag = magnitude();
         if (mag) {
             //this.scalarDivide(mag);
             this /= mag; // Not work
             this *= 1/mag; // Does work.

         }
     }

//    Vector3 opBinary(string op)(Vector3 rhs) if (op=='/')
     Vector3 opDiv(float scalar)
     {
         Vector3 v = this;
         v.scalarDivide(scalar);
         return v;
     }

}




More information about the Digitalmars-d-learn mailing list