Original Post
Hello all. I'm currently trying to learn Cplusplus (wont let me do the plus sign :S ) and its been going really well so far. But now it seems i've run into a problem that i can't figure out. I'm overloading operators and the problem is with the operator -. I've done: anyone here that can tell me why aObj = T1(10,0,0) - T1(0,0,5); dosn't work?
private:
int x;
int y;
int z;
public:
friend T1 operator -(const T1& a, const T2& b);
//Then:
T1 operator -(const T1& a, const T2& b)
{
T1 temp;
temp.x = a.x - b.x;
temp.y = a.y - b.y;
temp.z = a.z - b.z;
return temp;
}
//Then in my main function I've got:
aObj = aObj - T1(0,0,10); //this works.
aObj = T1(10,0,0) - T1(0,0,5); //this dosn't work.