Is this a operator overloading bug?
Tim Fang
no at spam.com
Thu Jan 11 06:47:08 PST 2007
Every member of "Vector3 ret" assigned a new value in the opMul(), It seams
need not to init "Vector3 ret". However if call ret.set(1,1,1), it works
well; if call ret.set(0,0,0), it return (0,0,0). I think this should be a
bug.
"mike" <vertex at gmx.at> wrote:op.tlzubjapnxkcto at zimmermoos...
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