problem with custom operators
Mar 14, 2011 at 4:53pm UTC
Hi,
I wanted to create a maths library with basic vector, matrix etc. operations.
I ran into this problem when I tried to use it:
1 2 3 4
myvec3f a = myvec3f(0.0f, 0.0f, 0.0f);
myvec3f b = myvec3f(1.0f, 0.0f, 1.0f);
f c = 2.0f;
a += b * c;
the compiler says:
../camera.cpp:97: error: no match for
Mar 14, 2011 at 5:09pm UTC
Define your operator+= this way:
myvec3f& operator +=(const myvec3f&);
Then in the implementation:
1 2 3 4 5
myvec3f& myvec3f::operator +=(const myvec3f& vec3f_to_add)
{
// code code code...
return *this ;
}
Define the rest of your member operator functions (assignment) in the same way.
Last edited on Mar 14, 2011 at 5:10pm UTC
Mar 14, 2011 at 5:10pm UTC
First of all, you should remove this:
You unnecessarily merge namespaces here, this completely breaks all advantages you gain from having namespaces in the first place. As to your test code... where do you put it?
Mar 14, 2011 at 5:33pm UTC
Thank you very much sadavied,
it solved the problem!!!
Best regards,
Yours3lf
Topic archived. No new replies allowed.