Vector addition

high i have a vector class with 1 default and 2 overloaded constructors that look like:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
Vect :: Vect()
{
     mode='r';
     x=0.0;
     y=0.0;
     mag=0.0;
     angl=0.0;    
}
////////////////////////////////////////////////////////////////////////////////
Vect :: Vect(double tempX,double tempY)
{
     mode='r';
     x=tempX;
     y=tempY;
     calcMag();
     calcAngl();
     
}
////////////////////////////////////////////////////////////////////////////////
Vect :: Vect(double tempX,double tempY,char tMode)
{
     tMode=tolower(tMode);
     if(tMode=='r')
     {
          setRect(&tempX,&tempY);
       
     }
     if(tMode=='p')
     {
          setPolar(&tempX ,&tempY);
     }     

}


and i have an overloaded addition operator that looks like this:
1
2
3
4
5
6
7
8
9
Vect Vect :: operator+(const Vect &rightVect)
{
     Vect temp;
     temp.x=rightVect.getX()+x;//why does this have direct acces?
     temp.y=rightVect.getY()+y;
     temp.setX(&temp.x);
     temp.setY(&temp.y);
     return temp;
}


and if i add a vect instance that was created with ether the second or third constructor they add just fine but if i try to add ether of them with the first constructor it returns this vect_test.cpp no match for 'operator+' in 'test1 + test2' any ideas what might be causing it?
1
2
3
4
5
6
7
     Vect test2();
     Vect test0(2.0,3.0,'r');
     Vect test1(2.0,1.0,'r');
     
     Vect test3(0,0,'r');
     test3=test1+test0;//this works
     //test2=test1+test2;//this doesnt work 

Thanks for any and all help : )

Last edited on
The compiler might mistake Vect test2(); as a function declaration. Try omit the ()
Thank you : ) problem solved
Topic archived. No new replies allowed.