I am having problems with my constructor in class World.
I created a 2D array with pointers where each entry in the array is of type Organism, hence the line of code:
Organism* grid[20][20];
When I run my program, I only see
hello
and after that, I get a message saying that my program has stopped working. I'm pretty sure it's the line of code
grid[i][j]->symbol = ' ';
that's causing the problem. Just to see what would happen, I changed that line to
grid[i][j];
and didn't get any errors. But, the moment I put ->, I seem to get errors.
Is there a reason why my program stops working after I put ->? Any help would be appreciated.
This is my code:
#include <iostream>
using namespace std;
class Organism
{
public: 
    char symbol;
};
class World
{
public:
    World();
private:
    Organism* grid[20][20];
};
int main()
{
    World world;
    return 0;
}
World::World()
{
    for(int i = 0; i < 20; i++)
        for(int j = 0; j < 20; j++)
        {
            cout << "hello" << endl;
            grid[i][j]->symbol = ' ';
            cout << "here" << endl;
        }
}
 
     
     
    