我有以下课程:
class solveMaze {
private:
maze maze;
mouse m;
stack<coords> coordStack;
int x;
int y;
coords currLoc;
public:
solveMaze();
};
在这里我得到一个错误的未定义引用“coords :: coords()”这是什么意思,我如何声明一个对象,我可以覆盖/使它像一个变量(如x和y)?
solveMaze::solveMaze() {
x = m.x;
y = m.y;
coords c(x, y);
currLoc = c;
coords lastLoc(c);
coordStack.push(c);
}
这是coords.h(删除不相关的运算符重载函数以缩短代码):
class coords {
public:
coords();
coords(int);
coords(int, int);
int x;
int y;
friend ostream &operator<<(ostream &output, const coords &c);
bool operator==(coords);
void operator=(const coords &b);
};
void coords::operator=(const coords &b){
x = b.x;
y = b.y;
}
coords::coords(int a, int b) {
x = a;
y = b;
}