Hi! I have made a class in whose private members i have included two arrays which I initialize in the class definition rather than the constructor. However, when i try to call any array of the two from a member function, the compiler shows this message:
direction directions[17][17] = { { N , RIGHT , N , N , N , N , DOWN , N , N , N , N , N , N , N , N , N , N },
{ LEFT , N , RIGHT , N , N , N , N , N , N , N , N , N , N , N , N , N , N },
{ N , LEFT , N , DOWN , N , N , N , N , N , N , N , N , N , N , N , N , N },
{ N , N , UP , N , LEFT , N , N , N , N , N , N , N , N , N , N , N , N },
{ N , N , N , RIGHT , N , UP , N , LEFT , N , N , N , N , N , N , N , N , N },
{ N , N , N , N , DOWN , N , UP , N , N , N , N , N , RIGHT , N , N , N , N },
{ UP , N , N , N , N , DOWN , N , N , N , N , N , N , N , N , N , N , N },
{ N , N , N , N , RIGHT , N , N , N , LEFT , N , N , N , N , DOWN , N , N , N },
{ N , N , N , N , N , N , N , RIGHT , N , UP , N , N , N , N , N , N , N },
{ N , N , N , N , N , N , N , N , DOWN , N , UP , N , N , N , LEFT , N , N },
{ N , N , N , N , N , N , N , N , N , DOWN , N , UP , N , N , N , LEFT , N },
{ N , N , N , N , N , N , N , N , N , N , DOWN , N , N , N , N , N , LEFT },
{ N , N , N , N , N , LEFT , N , N , N , N , N , N , N , N , N , N , N },
{ N , N , N , N , N , N , N , UP , N , N , N , N , N , N , N , N , N },
{ N , N , N , N , N , N , N , N , N , RIGHT , N , N , N , N , N , N , N },
{ N , N , N , N , N , N , N , N , N , N , RIGHT , N , N , N , N , N , N },
{ N , N , N , N , N , N , N , N , N , N , N , RIGHT , N , N , N , N , N } };
};
the problem arises when i call the get and set functions:
void Map::setAL(int a, int b, bool w)
{
adjacency_list[a][b] = w;
}
bool Map::getAL(int a, int b)
{
bool c = adjacency_list[a][b];
return c;
}
bool *Map::getAL()
{
return adjacency_list;
}
direction Map::getDirection(int a, int b)
{
direction dir = directions[a][b];
return dir;
}
and the compiler shows up the errors:
error C2065: 'adjacency_list' : undeclared identifier
error C2065: 'directions' : undeclared identifier
is that true for all types of variables or just arrays? how should i initialize them? should i initialize them in the constructor? any other obvious errors in my code?