Is this a operator overloading bug?

mike vertex at gmx.at
Thu Jan 11 06:24:45 PST 2007


Am 11.01.2007, 15:07 Uhr, schrieb Tim Fang <no at spam.com>:

> I have called "a.set(1,1,1)" to init the members in main().

Yeah, but

>>>  Vector3 opMul(float s)
>>>  {
>>>   Vector3 ret;
>>>   ret.x = x*s;
>>>   ret.y = y*s;
>>>   ret.z = z*s;
>>>   return ret;
>>>  }

creates a new, uninitialized Vector3 and returns it. This should work:

' Vector3 ret;
' ret.set(0., 0., 0.);
' // ...

-mike

-- 
Erstellt mit Operas revolutionärem E-Mail-Modul: http://www.opera.com/mail/



More information about the Digitalmars-d mailing list