problem with custom operators

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
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
First of all, you should remove this:
 
using namespace common;

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?
Thank you very much sadavied,

it solved the problem!!!

Best regards,
Yours3lf
Topic archived. No new replies allowed.