vector addition

high i have a vector class with 1 default and 2 overloaded constructors that look like:

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);
}

}
[/code]


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 : )
Vect test2(); is a function declaration.
Vect test2; is an object created with the default constructor.

Vect Vect :: operator+(const Vect &rightVect) const

Next time post the compiler message
vect_test.cpp no match for 'operator+' in 'test1 + test2'
i just forgot to bold it...But yes that was the isse thanks for the help : )
I mean the full message
In function ‘int main(int, char**)’:
11:14: error: no match for ‘operator+’ in ‘test1 + test2’
11:14: note: candidates are:
    vector vector::operator+(const vector&) const
      no known conversion for argument 1 from ‘vector()’ to ‘const vector&’

Topic archived. No new replies allowed.