I have a class for my console game engine, it has an array of characters for the map. In the constructor, I want to take parameters for the height and width of the map (the map is an array). I tried to declare and instantiate an array in the constructor however this array gets deleted after the constructor is done constructing. heres what it looked like:
class ConsoleGameEngine {
public:
ConsoleGameEngine(mapheight, mapwidth) {
char map[mapheight][mapwidth];
}
}
this didnt allow any other methods to access the map array as it was destroyed when the constructor finished. I want to do something like this:
class ConsoleGameEngine {
public:
char map;
ConsoleGameEngine(mapheight, mapwidth) {
map[mapheight][mapwidth];
}
}
i dont want to use vectors, i want to use normal arrays. Thank you for reading.