class Game: StateManager sm; update(): sm.update(); class StateManager: vector<State> states; update(): states.back().update(); pop(): if(states.size() == 1) exitGame(); else states.pop(); class DafuqState : State: StateManager* manager; DafuqState(StateManager* manager) : State(manager) {...} update(): // update, draw, whutever switch(keypress) { case ESC: manager->pop(); case "i": // do... } main: Game g; while(isRunning()): g.update();
Standard input is empty
prog.cpp:5: error: expected class-name before ‘sm’ prog.cpp:5: error: expected `{' before ‘sm’ prog.cpp:5: error: invalid type in declaration before ‘;’ token prog.cpp:8: error: ISO C++ forbids declaration of ‘update’ with no type prog.cpp: In function ‘int update()’: prog.cpp:8: error: only constructors take base initializers prog.cpp:9: error: expected `(' before ‘.’ token prog.cpp:9: error: expected `{' before ‘.’ token prog.cpp: At global scope: prog.cpp:9: error: expected unqualified-id before ‘.’ token prog.cpp:15: error: expected template-name before ‘<’ token prog.cpp:15: error: expected `{' before ‘<’ token prog.cpp:15: error: expected unqualified-id before ‘<’ token prog.cpp:17: error: ISO C++ forbids declaration of ‘update’ with no type prog.cpp: In function ‘int update()’: prog.cpp:17: error: redefinition of ‘int update()’ prog.cpp:8: error: ‘int update()’ previously defined here prog.cpp:17: error: only constructors take base initializers prog.cpp:18: error: expected `(' before ‘.’ token prog.cpp:18: error: expected `{' before ‘.’ token prog.cpp: At global scope: prog.cpp:18: error: expected unqualified-id before ‘.’ token prog.cpp:21: error: ISO C++ forbids declaration of ‘pop’ with no type prog.cpp: In function ‘int pop()’: prog.cpp:21: error: only constructors take base initializers prog.cpp:22: error: expected identifier before ‘if’ prog.cpp:22: error: expected `(' before ‘if’ prog.cpp:22: error: expected `{' before ‘if’ prog.cpp: At global scope: prog.cpp:22: error: expected unqualified-id before ‘if’ prog.cpp:24: error: expected unqualified-id before ‘else’ prog.cpp:29: error: expected class-name before ‘:’ token prog.cpp:29: error: expected `{' before ‘:’ token prog.cpp:29: error: expected unqualified-id before ‘:’ token prog.cpp:32: error: expected `)' before ‘*’ token prog.cpp:34: error: ISO C++ forbids declaration of ‘update’ with no type prog.cpp: In function ‘int update()’: prog.cpp:34: error: redefinition of ‘int update()’ prog.cpp:8: error: ‘int update()’ previously defined here prog.cpp:34: error: only constructors take base initializers prog.cpp:36: error: expected identifier before ‘switch’ prog.cpp:36: error: expected `(' before ‘switch’ prog.cpp:36: error: expected `{' before ‘switch’ prog.cpp: At global scope: prog.cpp:36: error: expected unqualified-id before ‘switch’ prog.cpp:48: error: function definition does not declare parameters prog.cpp:51: error: expected unqualified-id before ‘while’
Standard output is empty