Hi all, I'm having this really strange problem with operator overloading, I copied it from a tutorial that was done on windows, they didn't seem to have a problem, I think it might be compiler specific.
It is a program to multiply, add and subtract vectors;
What really makes it wierd is the way that, for example:
//this works
Vector vect4 = vect3 * 2;
/*this does not
Vector vect4;
vect4 = vect3 * 2;
*/
- You can't bind a temporary to a non-const reference.
a temporary is returned from your operations, now check the assignment operator Point operator=(Point &p)
- You shouldn't code unnecessary things.
The assignment operator provided by the compiler was good enough.
Actually, it was better than your attempt as it worked with temporaries
- You ought to respect const-correctness
If a function would not modify the object, you should mark it as `const', otherwise you can't use a function with a constant object