しかし、以下の内容でプログラムを書き進めることができません。
class Map{
int **map;
int old_limit_h;//動的map[][] 解放用 縦幅
public:
static void create_map(int,int);//Map variable
static int view_map(int,int);
static void input_map(int,int,int);//w,h,data
static void destruct_map();//Destructing map variable
};
void Map::create_map(int h,int w){
map = new int*[h]; //<- ここでmapの参照エラーが出てきて困ってます!!以下のmapも参照エラーを起こしてます。
for (int i = 0; i < h; i++) {
map[i] = new int[w];
}
old_limit_h = h; //<- mapだけではなく old_limit_hも参照エラーを起こしてます。
}
int Map::view_map(int h,int w){
return (map[h][w]);
}
void Map::input_map(int h, int w, int data){
map[h][w] = data;
}
void Map:destruct_map(){
for (int i = 0; i < old_limit_h; i++) {
delete[] map[i];
}
delete[] map;
}
エラーの内容は
静的でないメンバ 'Map::map' への参照が正しくありません。
静的でないメンバ 'Map::old_limit_h' への参照が正しくありません。
'Map::map': 関数呼び出しには引数リストがありません。メンバへのポインタを作成するために '&Map::map' を使用してください
配列または、ポインタでない変数に添字が使われました。
という内容です。
本やほかのサイトで文法について調べましたが原因が分かりません。
動的確保の仕方が間違っているのでしょうか? ご回答お願い致します。
前回、私の疑問を解決してくださった方、この質問をご覧になっていらっしゃらないかと思いますが、ここでお礼を申し上げます。