我在尝试填充一个包含我创建的类的对象的二维数组时遇到问题。错误是:
error C2679: binary '=' : no operator found which takes a right-hand operand of type 'Cell *' (or there is no acceptable conversion)
产生错误的代码如下:
摘自 main.cpp
Cell cells[80][72];
for(int x = 0; x < 80; x++){
for(int y = 0; y < 72; y++){
cells[x][y] = new Cell();
}
}
摘自 cell.hpp
class Cell
{
public:
Cell();
int live;
int neighbours;
};
摘自 cell.cpp
Cell::Cell()
{
srand(time(0));
this->live = rand() % 2;
this->neighbours = 0;
}
我怀疑我需要对 Cell 类的构造函数进行某种重载,但我不知道如何为这种情况实现一个。