fork download
  1. //GState.h//
  2. #include "GStateFlow.h"
  3. class GStateFlow;
  4. class GState
  5. {
  6. public:
  7. virtual void NextState(GStateFlow* State)=0;
  8. };
  9. class LoaderStateUNKNOWN:public GState
  10. {
  11. public:
  12. virtual void NextState(GStateFlow* State)
  13. {
  14. ShowMessage("State is UNKNOWN,turn to Reset");
  15. State->SetState(new LoaderStateRESET());
  16. }
  17. };
  18. class LoaderStateRESET:public GState
  19. {
  20. public:
  21. virtual void NextState(GStateFlow* State)
  22. {
  23. ShowMessage("State is Reset.");
  24. }
  25. };
  26.  
  27. //GStateFlow.h
  28. #include "GState.h"
  29. class GState;
  30. class GStateFlow
  31. {
  32. public:
  33. GStateFlow(){this->CurrentState = new LoaderStateUNKNOWN();}
  34. ~GStateFlow(){delete CurrentState;}
  35. void SetState(GState* State){CurrentState=State;}
  36. void NextState(){CurrentState->NextState(this);}
  37. protected:
  38. GState* CurrentState;
  39. };
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:2:24: error: GStateFlow.h: No such file or directory
prog.cpp:28:20: error: GState.h: No such file or directory
prog.cpp: In member function ‘virtual void LoaderStateUNKNOWN::NextState(GStateFlow*)’:
prog.cpp:14: error: ‘ShowMessage’ was not declared in this scope
prog.cpp:15: error: invalid use of incomplete type ‘struct GStateFlow’
prog.cpp:3: error: forward declaration of ‘struct GStateFlow’
prog.cpp:15: error: expected type-specifier before ‘LoaderStateRESET’
prog.cpp:15: error: expected `)' before ‘LoaderStateRESET’
prog.cpp: In member function ‘virtual void LoaderStateRESET::NextState(GStateFlow*)’:
prog.cpp:23: error: ‘ShowMessage’ was not declared in this scope
stdout
Standard output is empty