Note that there are some explanatory texts on larger screens.

plurals
  1. POError: expected initializer before '.' token
    text
    copied!<p>I am fairly new to using classes and the Object Oriented side of C++ and get the error in the title.</p> <p>I am writing a game of Tetris using SDL.</p> <p>I have a class definition in shapes.h</p> <pre><code>class shape { public: SDL_Surface *colour; int rotation1[4][4]; int rotation2[4][4]; int rotation3[4][4]; int rotation4[4][4]; bool load(); void move(); shape(); }; </code></pre> <p>and in main.h i have included shapes.h and defined instances of the class with</p> <pre><code>//Create shapes shape O, T, S, L, R, Z, I; </code></pre> <p>I also have seperate files for each shape such as I.cpp as each shape will have different code for loading the image for its colour of block onto the SDL_Surface colour and for the various arrays of different rotations of the block, so i seperated this into one file for each block.</p> <p>In I.cpp I have included main.h and tried to set up the load function for I as follows:</p> <pre><code>bool I.load() { //if loading the cyan square texture fails if ((I.colour = surface::onLoad("../Textures/cyanSquare.png")) == NULL) { //print error cout &lt;&lt; "Unable to load cyanSquare.png"; //return fail return false; } I.rotation1 = {{7,7,7,7}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}}; I.rotation2 = {{0,0,7,0}, {0,0,7,0}, {0,0,7,0}, {0,0,7,0}}; I.rotation3 = {{7,7,7,7}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}}; I.rotation4 = {{0,0,7,0}, {0,0,7,0}, {0,0,7,0}, {0,0,7,0}}; return true; } </code></pre> <p>When I try to compile this (using GCC) it reports an error on line 3 of I.cpp of:</p> <pre><code>error: expected initializer before '.' token </code></pre> <p>I have absolutely no idea what this means, and could not find anything of use searching google for this error code, so any help would be appreciated.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload