Consider I have this piece of code:
#include <iostream>
using namespace std;
enum TEXTURE { SAND, GRASS, DIRT, ROCK, SNOW };
class grid
{
public:
TEXTURE type;
string str;
};
grid layer[5];
int main()
{
layer[0].str = "AAAAA";
layer[1].str = "A A A";
layer[2].str = " A A ";
layer[3].str = " A ";
layer[4].str = "AA AA";
grid *ptr;
ptr = &layer[0];
if(*ptr.str.at(1) == 'A')
cout << "TRUE!\n";
}
When I attempt to compile, it give me this error:
error: request for member str in ptr, which is of non-class type grid*
*I want to fix this so I can access the member variable str through ptr.
How do I fix it?