Hello,
I am having a problem with my code here. The program does not work properly. I think the problem come from setDimension or the loop. World[a][b] does not work correctly.
prog.cpp: In member function ‘void GOL::random()’:
prog.cpp:75:26: error: ‘rand’ was not declared in this scope
int x = rand() % 2;
^
You need to include the header that contains the rand function. You might also want to seed the random function at the beginning of main so you don't get the same random number each time.
You didn't say what was going wrong with those lines. A better description would help us debug your problems.
However, I think you can find your problem by comparing lines 57 and 77 (0 vs. 1) with lines 45, 91 (etc.), 126 and 134 (' ', '-', and '*'). You are inconsistent with how you represent a living cell.
Thanks for the answer.
The problem is i dont know what is wrong with the lines. VS13 is showing me an arrow on line 126 with the note "memory cannot be read" (translated).
The main problem I saw, was that you never created a world. So, the program stopped when trying to access it. I fiddled with your code, and it seems to be working now. You may want to use a gotoXY() function to start drawing the colony always in the same place, so the screen doesn't scroll, or, use a clearscreen() function. Anyway, here's the code I corrected.