I want to make a class that will allow me to create a "CharMap" object so I can output them (2D char arrays) a certain way. The class has the data members m_height, m_width, and the 2D character array.
Right now I'm creating the character array I want, then passing the constructor the width and height, but I don't know how to pass it the actual array ONLY because the height and width are variable.
I want to keep it as a character array because I can format it nicely, like this:
1 2 3 4 5 6
|
char myMap[5][10] = {
{"+========+"},
{"| |"},
{"| |"},
{"| |"},
{"+========+"} };
| |
The problem is, if I try to pass that to, say, a function CharMap::setMap();, I need to tell it the height and width right? But if I set them to the data members "m_height" and "m_width", I want to use them in the function prototype to tell it how big of an array to get (as set by the constructor), but I can't use data members in the prototype it seems, since this gives me an error:
void setMap( myMap[m_height][m_width] );
I tried using pointers and char**, but I think I'm getting in too deep here, all I want to do is be able to pass an array (of variable height and width) to a function that will output it in a special way, rather than copying the code (for my special output) after each character array I create.