Alright, I just got finished making a function for some code I’m making, which will end up to be Conway’s Game of Life, but I am getting some unexpected errors.
Here is the code:
http://tinypaste.com/244cf522
The errors are:
error: name lookup of ‘q’ changed for ISO ‘for’ scoping
error: expected initializer before ‘while’
The scope of
qis limited to theforloop in which it was declared; any variables that are declared in the initialisation part of aforloop are treated this way.You need to change the scope of
qto last even after theforloop’s scope is gone. To do this, simply movefrom in the
forto above theforand changeto
So your whole thing would look like
or
Also, this isn’t a new rule 🙂