When creating a multidimensional array im getting the following error:
a non static member reference must be relative to a specific object c++
My code:
class Level
{
private:
int width = 6;
int height = 6;
Room rooms[width][height];
public:
Level();
~Level();
};
When width and height are replaced, when creating the array, with 6 (the value of the int's) it works. Why can't I use an int that holds the same value?
I don't need variable sizes (else I should use a vector), I thought using some variables would make it more readable for others when reading it.
In my constructor im going to fill the array in a for loop like:
Level::Level(int id)
{
for (int i = 0; i < levelWidth; i++)
{
for (int x = 0; x < levelHeight; x++)
{
//Do the filling here
}
}
}