Hi! I am new to the forum and new to c++.
What i want is to create a simple project that
a)it will have a class named Map and it will create the map depending the size of it and now the hardest part,
b)I want to "sent" that map to a void that it will print that map. I have worked it a liitle bit but i don't really know how to make the (b) part.
Here is the code i've worked so far.
#include <iostream>
#include <string>
usingnamespace std;
class Map
{
public:
void showMap(char *);
char createMap(int );
};
char Map::createMap(int size)
{
char mmap[size][size];
int i,j;
for (int i=0;i<size; i++)
{
for (int j=0;j<size;j++)
{
mmap[i][j]='_';
}
}
// Here i want it to return the map.. And sent it to showMap
//Any ideas?
}
int main()
{
Map w1;
w1.createMap(39);
return 0;
}
I think you should learn a bit more before doing this.
I'll just point out your errors here:
class Map does not contain any data in it. What it should contain is the array. Right now, you may as well turn those methods into normal functions.
createMap is declared to return a char, which is a single char. It can't possibly contain the whole map.
mmap is a static array with variables for dimensions. That is not legal. Either look into dynamic arrays or make the sizes constant.
You're declaring i and j twice.