fork download
  1.  
  2.  
  3.  
  4. class Game:
  5. StateManager sm;
  6.  
  7.  
  8. update():
  9. sm.update();
  10.  
  11.  
  12.  
  13.  
  14. class StateManager:
  15. vector<State> states;
  16.  
  17. update():
  18. states.back().update();
  19.  
  20.  
  21. pop():
  22. if(states.size() == 1)
  23. exitGame();
  24. else
  25. states.pop();
  26.  
  27.  
  28.  
  29. class DafuqState : State:
  30. StateManager* manager;
  31.  
  32. DafuqState(StateManager* manager) : State(manager) {...}
  33.  
  34. update():
  35. // update, draw, whutever
  36. switch(keypress)
  37. {
  38. case ESC:
  39. manager->pop();
  40. case "i":
  41. // do...
  42. }
  43.  
  44.  
  45.  
  46.  
  47.  
  48. main:
  49. Game g;
  50.  
  51. while(isRunning()):
  52. g.update();
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
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’
stdout
Standard output is empty