I working on a game but I have a problem with the initialization of the level. (feld is just field in german)
class level{
private:
feld spielfeld[10][10];
public:
/*
other stuff
*/
void init_feld();
};
void level::init_feld()
{
for(int i=0;i!=10;i++){
for(int n=0;n!=10;n++){
spielfeld[i][n] = new feld(land, i, n);
}
}
}
The Error:
Error: no match for »operator=« in »((level*)this)->level::spielfeld[i][n] = (operator new(24u), (, ((feld*))))« /home/nick/stratego/feld.h:18:11:
Remark: candidate is: feld& feld::operator=(const feld&) Process terminated with status 1 (0 minutes, 0 seconds) 2 errors, 0 warnings
spielfeld[i][n]is afeldobject,new feld(land, i, n)dynamically allocates anew feldobject and returns a pointer to that object. If you want to assign to afeldvalue tospielfeld[i][n]you could use:Alternatively you may be able to set the appropriate members of
spielfeld[i][n]directly or using other member functions.