I have a vector class and I want to overload some operators for it, so I made the class like this:(with other stuff too) But when I try to compile this:Code:class vec {
public:
float x, y;
vec(float setx = 0, float sety = 0) {
set(setx,sety);
}
vec(vec& rhs) {
x = rhs.x;
y = rhs.y;
}
vec operator=(vec& rhs) {
x = rhs.x;
y = rhs.y;
return rhs;
}
vec operator+(vec& rhs) {
vec ret(x+rhs.x,y+rhs.y);
return ret;
}
};
I get errors about that operator not existing like:Code:vec a, b, c;
a = b + c;
I was totally sure this was how to overload operators, but now I'm not so sure. What am I doing wrong?Quote:
7 C:\Dev-Cpp\antigrav\main.cpp no match for 'operator=' in 'a = vec::operator+(vec&)(((vec&)(&c)))'