bobby1112
26-05-2010, 14:05
salve raga come da titolo devo restituire un matrice di char dichiarata in questo modo
file .h
#ifndef MAP_H
#define MAP_H
#define MAX_SIZE 36
class Map {
private :
static const char earth[MAX_SIZE][MAX_SIZE];
const char** earthPtr;
public :
void printEarth();
const char** getEarth();
};
#endif
file .cpp
#include <iostream>
#include "Map.h"
using namespace std;
const char Map::earth[36][36]={
/*0*/ "************* ********************",
/*1*/ "* * * *",
/*2*/ "* * * *",
/*3*/ "* ** * ** *",
/*4*/ "* ** * ** *",
/*5*/ "* * * *",
/*6*/ "* *** * * *",
/*7*/ "* * * * ****** *",
/*8*/ "* * * * *",
/*9*/ "* * * * *",
/*10*/ "* * ********** *",
/*11*/ "* * * *",
/*12*/ "* * *",
/*13*/ "* *",
/*14*/ "* * * * *",
/*15*/ "***********************************",
// 01234567890123456789012345678901234
};
void Map::printEarth()
{
for(int i=0;i<=36;i++)
{
cout<<endl;
for(int j=0;j<36;j++)
cout<<earth[i][j];
}
}
const char** Map::getEarth()
{
earthPtr=&earth[0][0];
return earthPtr;
}
earthPtr=&earth[0][0]; in questa istruzione mi da questo errore
impossibile convertire da 'const char *' a 'const char **'
file .h
#ifndef MAP_H
#define MAP_H
#define MAX_SIZE 36
class Map {
private :
static const char earth[MAX_SIZE][MAX_SIZE];
const char** earthPtr;
public :
void printEarth();
const char** getEarth();
};
#endif
file .cpp
#include <iostream>
#include "Map.h"
using namespace std;
const char Map::earth[36][36]={
/*0*/ "************* ********************",
/*1*/ "* * * *",
/*2*/ "* * * *",
/*3*/ "* ** * ** *",
/*4*/ "* ** * ** *",
/*5*/ "* * * *",
/*6*/ "* *** * * *",
/*7*/ "* * * * ****** *",
/*8*/ "* * * * *",
/*9*/ "* * * * *",
/*10*/ "* * ********** *",
/*11*/ "* * * *",
/*12*/ "* * *",
/*13*/ "* *",
/*14*/ "* * * * *",
/*15*/ "***********************************",
// 01234567890123456789012345678901234
};
void Map::printEarth()
{
for(int i=0;i<=36;i++)
{
cout<<endl;
for(int j=0;j<36;j++)
cout<<earth[i][j];
}
}
const char** Map::getEarth()
{
earthPtr=&earth[0][0];
return earthPtr;
}
earthPtr=&earth[0][0]; in questa istruzione mi da questo errore
impossibile convertire da 'const char *' a 'const char **'