So I have a private member in the class Map
:
char **_map;
I then try to initialize the pointer array to a two dimensional char
array like this:
std::vector<std::string> contents = StringUtils::split(_mapInfo.getContents(), ' ');
const int x = StringUtils::toInt(contents.at(0));
const int y = StringUtils::toInt(contents.at(1));
_map = new char[x][y];
Basically the contents
vector contains two strings, which I then convert into integers. I then try to initialize the map
array but I receive this error:
Error 1 error C2540: non-constant expression as array bound
And this:
Error 2 error C2440: '=' : cannot convert from 'char (*)[1]' to 'char **'
And finally this:
3 IntelliSense: expression must have a constant value
The last error references the variable y
Can anyone explain what is happening and how I can fix it?