I'm having a problem with two lines of code. The errors are:
|line 4|error: expected constructor, destructor, or type conversion before '(' token|
|line 50|error: expected primary-expression before '!=' token|
Here are the code bits:
OPairType::OPairType (x=0, y=0);
and
return != (lh.x == rh.x && lh.y == rh.y);
If you need any more of the code, just leave a comment and I will supply it. Thank you for any help.
Edit: 11/7/2013: Here is the header code:
class OPairType{
private:
int x;
int y;
public:
OPairType (int=0, int=0);
int getX() const;
int getY() const;
void setX(int);
void setY(int);
void setValues(int, int);
friend OPairType operator + (OPairType, OPairType);
friend OPairType operator - (OPairType, OPairType);
friend bool operator == (OPairType, OPairType);
friend bool operator != (OPairType, OPairType);
friend std::ostream& operator << (std::ostream&, OPairType);
And here is the .cpp code:
#include "OPairType.h"
#include <iostream>
OPairType::OPairType (int x, int y);
int OPairType::getX() const {
return x;
}
int OPairType::getY() const {
return y;
}
void OPairType::setX(int new_x) {
x = new_x;
}
void OPairType::setY(int new_y) {
y = new_y;
}
void OPairType::setValues (int new_x, int new_y){
x = new_x;
y = new_y;
}
OPairType operator + (OPairType lh, OPairType rh){
OPairType answer;
answer.x = lh.x + rh.x;
answer.y = lh.y + rh.y;
return answer;
}
OPairType operator - (OPairType lh, OPairType rh){
OPairType answer;
answer.x = lh.x - rh.x;
answer.y = lh.y - rh.y;
return answer;
}
bool operator == (OPairType lh, OPairType rh){
return lh.x == rh.x && lh.y == rh.y;
}
bool operator != (OPairType lh, OPairType rh){
return !(lh.x == rh.x && lh.y == rh.y);
}
std::ostream& operator << (std::ostream& out, OPairType c){
out << "(" << c.x << ", " << c.y << ")";
return out;
}