这可能是一个非常基本的 C++ 问题,但我有点生疏。我正在尝试建立一个带有点的迷宫类型数据结构。这是我的代码。
class Point{
public :
int xCoord;
int yCoord;
bool visited;
//constructors
Point(){}
Point(int x, int y){
xCoord = x;
yCoord = y;
visited = false;
}
int makeVisited(){
visited = true;
}
int makeUnvisited(){
visited = false;
}
};
class Maze{
public :
int width;
int height;
Point ** grid;
//constructors
Maze(){}
Maze(int X, int Y){
width = X;
height = Y;
grid = new Point*[width];
for(int i = 0; i < width; i++){
grid[i] = new Point[height];
for(int j = 0; j < height; j++){
grid[i][j] = new Point(i, j);
}
}
}
}; //end of Maze class
当我尝试分配 grid[i][j] 一个新的点实例时,我收到一条错误消息
"error no operator "=" 匹配这些操作数"
有人能告诉我我在初始化点对象时做错了什么吗?