cypher543
11-24-2006, 08:57 AM
Well, as you can see from the title, I'm having a bit of trouble here... I'm trying to implement a GameState system so I can easily switch between the menu, the game, the pause screen, and the intro sequence. But, I get a ton of errors, all of which I just don't understand how to fix. Some related to creating a vector without a type (even though a type is specified), others are about undefined classes (which are defined) and others are about pure virtual functions and abstract types.
I'm new to the C++ scene (well, kind of... I just don't understand some of the OO aspects yet), so forgive me if these are caused by really stupid mistakes on my part.
You can download the source here: http://www.cypherspace.info/gamestate.tar.gz
The output of make is:
$ make
g++ -Iinclude -o ghost main.cpp GameManager.cpp IntroState.cpp MenuState.cpp PlayState.cpp PauseState.cpp
include/GameState.h:12: error: ‘GameManager’ has not been declared
include/GameState.h:13: error: ‘GameManager’ has not been declared
include/GameState.h:14: error: ‘GameManager’ has not been declared
include/GameState.h:15: error: ‘GameManager’ has not been declared
include/GameState.h: In member function ‘void GameState::changeState(int*, GameState*)’:
include/GameState.h:16: error: request for member ‘changeState’ in ‘* game’, which is of non-class type ‘int’
include/GameManager.h: At global scope:
include/GameManager.h:20: error: ISO C++ forbids declaration of ‘vector’ with no type
include/GameManager.h:20: error: expected ‘;’ before ‘<’ token
include/IntroState.h:21: error: cannot declare variable ‘IntroState::m_IntroState’ to be of abstract type ‘IntroState’
include/IntroState.h:6: note: because the following virtual functions are pure within ‘IntroState’:
include/GameState.h:12: note: virtual void GameState::handleEvents(int*)
include/GameState.h:13: note: virtual void GameState::update(int*)
include/GameState.h:14: note: virtual void GameState::draw(int*)
main.cpp: In function ‘int main(int, char**)’:
main.cpp:7: error: request for member ‘init’ in ‘game’, which is of non-class type ‘GameManager*’
main.cpp:8: error: request for member ‘changeState’ in ‘game’, which is of non-class type ‘GameManager*’
main.cpp:10: error: request for member ‘isRunning’ in ‘game’, which is of non-class type ‘GameManager*’
main.cpp:11: error: request for member ‘handleEvents’ in ‘game’, which is of non-class type ‘GameManager*’
main.cpp:13: error: request for member ‘draw’ in ‘game’, which is of non-class type ‘GameManager*’
main.cpp:16: error: request for member ‘cleanup’ in ‘game’, which is of non-class type ‘GameManager*’
include/GameState.h:12: error: ‘GameManager’ has not been declared
include/GameState.h:13: error: ‘GameManager’ has not been declared
include/GameState.h:14: error: ‘GameManager’ has not been declared
include/GameState.h:15: error: ‘GameManager’ has not been declared
include/GameState.h: In member function ‘void GameState::changeState(int*, GameState*)’:
include/GameState.h:16: error: request for member ‘changeState’ in ‘* game’, which is of non-class type ‘int’
include/GameManager.h: At global scope:
include/GameManager.h:20: error: ISO C++ forbids declaration of ‘vector’ with no type
include/GameManager.h:20: error: expected ‘;’ before ‘<’ token
GameManager.cpp: In member function ‘void GameManager::cleanup()’:
GameManager.cpp:14: error: ‘states’ was not declared in this scope
GameManager.cpp: In member function ‘void GameManager::changeState(GameState*)’:
GameManager.cpp:25: error: ‘states’ was not declared in this scope
GameManager.cpp:31: error: ‘states’ was not declared in this scope
GameManager.cpp: In member function ‘void GameManager::pushState(GameState*)’:
GameManager.cpp:38: error: ‘states’ was not declared in this scope
GameManager.cpp:43: error: ‘states’ was not declared in this scope
GameManager.cpp: In member function ‘void GameManager::popState()’:
GameManager.cpp:50: error: ‘states’ was not declared in this scope
GameManager.cpp:56: error: ‘states’ was not declared in this scope
GameManager.cpp: In member function ‘void GameManager::handleEvents()’:
GameManager.cpp:65: error: ‘states’ was not declared in this scope
GameManager.cpp: In member function ‘void GameManager::update()’:
GameManager.cpp:71: error: ‘states’ was not declared in this scope
GameManager.cpp: In member function ‘void GameManager::draw()’:
GameManager.cpp:77: error: ‘states’ was not declared in this scope
include/GameState.h:12: error: ‘GameManager’ has not been declared
include/GameState.h:13: error: ‘GameManager’ has not been declared
include/GameState.h:14: error: ‘GameManager’ has not been declared
include/GameState.h:15: error: ‘GameManager’ has not been declared
include/GameState.h: In member function ‘void GameState::changeState(int*, GameState*)’:
include/GameState.h:16: error: request for member ‘changeState’ in ‘* game’, which is of non-class type ‘int’
include/GameManager.h: At global scope:
include/GameManager.h:20: error: ISO C++ forbids declaration of ‘vector’ with no type
include/GameManager.h:20: error: expected ‘;’ before ‘<’ token
include/IntroState.h:21: error: cannot declare variable ‘IntroState::m_IntroState’ to be of abstract type ‘IntroState’
include/IntroState.h:6: note: because the following virtual functions are pure within ‘IntroState’:
include/GameState.h:12: note: virtual void GameState::handleEvents(int*)
include/GameState.h:13: note: virtual void GameState::update(int*)
include/GameState.h:14: note: virtual void GameState::draw(int*)
include/MenuState.h:21: error: cannot declare variable ‘MenuState::m_MenuState’ to be of abstract type ‘MenuState’
include/MenuState.h:6: note: because the following virtual functions are pure within ‘MenuState’:
include/GameState.h:12: note: virtual void GameState::handleEvents(int*)
include/GameState.h:13: note: virtual void GameState::update(int*)
include/GameState.h:14: note: virtual void GameState::draw(int*)
IntroState.cpp:7: error: cannot declare variable ‘IntroState::m_IntroState’ to be of abstract type ‘IntroState’
include/IntroState.h:6: note: since type ‘IntroState’ has pure virtual functions
IntroState.cpp:24: error: no ‘void IntroState::pesume()’ member function declared in class ‘IntroState’
include/GameState.h:12: error: ‘GameManager’ has not been declared
include/GameState.h:13: error: ‘GameManager’ has not been declared
include/GameState.h:14: error: ‘GameManager’ has not been declared
include/GameState.h:15: error: ‘GameManager’ has not been declared
include/GameState.h: In member function ‘void GameState::changeState(int*, GameState*)’:
include/GameState.h:16: error: request for member ‘changeState’ in ‘* game’, which is of non-class type ‘int’
include/GameManager.h: At global scope:
include/GameManager.h:20: error: ISO C++ forbids declaration of ‘vector’ with no type
include/GameManager.h:20: error: expected ‘;’ before ‘<’ token
include/MenuState.h:21: error: cannot declare variable ‘MenuState::m_MenuState’ to be of abstract type ‘MenuState’
include/MenuState.h:6: note: because the following virtual functions are pure within ‘MenuState’:
include/GameState.h:12: note: virtual void GameState::handleEvents(int*)
include/GameState.h:13: note: virtual void GameState::update(int*)
include/GameState.h:14: note: virtual void GameState::draw(int*)
include/PlayState.h:21: error: cannot declare variable ‘PlayState::m_PlayState’ to be of abstract type ‘PlayState’
include/PlayState.h:6: note: because the following virtual functions are pure within ‘PlayState’:
include/GameState.h:12: note: virtual void GameState::handleEvents(int*)
include/GameState.h:13: note: virtual void GameState::update(int*)
include/GameState.h:14: note: virtual void GameState::draw(int*)
MenuState.cpp:7: error: cannot declare variable ‘MenuState::m_MenuState’ to be of abstract type ‘MenuState’
include/MenuState.h:6: note: since type ‘MenuState’ has pure virtual functions
include/GameState.h:12: error: ‘GameManager’ has not been declared
include/GameState.h:13: error: ‘GameManager’ has not been declared
include/GameState.h:14: error: ‘GameManager’ has not been declared
include/GameState.h:15: error: ‘GameManager’ has not been declared
include/GameState.h: In member function ‘void GameState::changeState(int*, GameState*)’:
include/GameState.h:16: error: request for member ‘changeState’ in ‘* game’, which is of non-class type ‘int’
include/GameManager.h: At global scope:
include/GameManager.h:20: error: ISO C++ forbids declaration of ‘vector’ with no type
include/GameManager.h:20: error: expected ‘;’ before ‘<’ token
include/PauseState.h:21: error: cannot declare variable ‘PauseState::m_PauseState’ to be of abstract type ‘PauseState’
include/PauseState.h:6: note: because the following virtual functions are pure within ‘PauseState’:
include/GameState.h:12: note: virtual void GameState::handleEvents(int*)
include/GameState.h:13: note: virtual void GameState::update(int*)
include/GameState.h:14: note: virtual void GameState::draw(int*)
include/PlayState.h:21: error: cannot declare variable ‘PlayState::m_PlayState’ to be of abstract type ‘PlayState’
include/PlayState.h:6: note: because the following virtual functions are pure within ‘PlayState’:
include/GameState.h:12: note: virtual void GameState::handleEvents(int*)
include/GameState.h:13: note: virtual void GameState::update(int*)
include/GameState.h:14: note: virtual void GameState::draw(int*)
PlayState.cpp:7: error: cannot declare variable ‘PlayState::m_PlayState’ to be of abstract type ‘PlayState’
include/PlayState.h:6: note: since type ‘PlayState’ has pure virtual functions
include/GameState.h:12: error: ‘GameManager’ has not been declared
include/GameState.h:13: error: ‘GameManager’ has not been declared
include/GameState.h:14: error: ‘GameManager’ has not been declared
include/GameState.h:15: error: ‘GameManager’ has not been declared
include/GameState.h: In member function ‘void GameState::changeState(int*, GameState*)’:
include/GameState.h:16: error: request for member ‘changeState’ in ‘* game’, which is of non-class type ‘int’
include/GameManager.h: At global scope:
include/GameManager.h:20: error: ISO C++ forbids declaration of ‘vector’ with no type
include/GameManager.h:20: error: expected ‘;’ before ‘<’ token
include/PauseState.h:21: error: cannot declare variable ‘PauseState::m_PauseState’ to be of abstract type ‘PauseState’
include/PauseState.h:6: note: because the following virtual functions are pure within ‘PauseState’:
include/GameState.h:12: note: virtual void GameState::handleEvents(int*)
include/GameState.h:13: note: virtual void GameState::update(int*)
include/GameState.h:14: note: virtual void GameState::draw(int*)
include/MenuState.h:21: error: cannot declare variable ‘MenuState::m_MenuState’ to be of abstract type ‘MenuState’
include/MenuState.h:6: note: because the following virtual functions are pure within ‘MenuState’:
include/GameState.h:12: note: virtual void GameState::handleEvents(int*)
include/GameState.h:13: note: virtual void GameState::update(int*)
include/GameState.h:14: note: virtual void GameState::draw(int*)
PauseState.cpp:7: error: cannot declare variable ‘PauseState::m_PauseState’ to be of abstract type ‘PauseState’
include/PauseState.h:6: note: since type ‘PauseState’ has pure virtual functions
make: *** [all] Error 1
Can anyone help?
I'm new to the C++ scene (well, kind of... I just don't understand some of the OO aspects yet), so forgive me if these are caused by really stupid mistakes on my part.
You can download the source here: http://www.cypherspace.info/gamestate.tar.gz
The output of make is:
$ make
g++ -Iinclude -o ghost main.cpp GameManager.cpp IntroState.cpp MenuState.cpp PlayState.cpp PauseState.cpp
include/GameState.h:12: error: ‘GameManager’ has not been declared
include/GameState.h:13: error: ‘GameManager’ has not been declared
include/GameState.h:14: error: ‘GameManager’ has not been declared
include/GameState.h:15: error: ‘GameManager’ has not been declared
include/GameState.h: In member function ‘void GameState::changeState(int*, GameState*)’:
include/GameState.h:16: error: request for member ‘changeState’ in ‘* game’, which is of non-class type ‘int’
include/GameManager.h: At global scope:
include/GameManager.h:20: error: ISO C++ forbids declaration of ‘vector’ with no type
include/GameManager.h:20: error: expected ‘;’ before ‘<’ token
include/IntroState.h:21: error: cannot declare variable ‘IntroState::m_IntroState’ to be of abstract type ‘IntroState’
include/IntroState.h:6: note: because the following virtual functions are pure within ‘IntroState’:
include/GameState.h:12: note: virtual void GameState::handleEvents(int*)
include/GameState.h:13: note: virtual void GameState::update(int*)
include/GameState.h:14: note: virtual void GameState::draw(int*)
main.cpp: In function ‘int main(int, char**)’:
main.cpp:7: error: request for member ‘init’ in ‘game’, which is of non-class type ‘GameManager*’
main.cpp:8: error: request for member ‘changeState’ in ‘game’, which is of non-class type ‘GameManager*’
main.cpp:10: error: request for member ‘isRunning’ in ‘game’, which is of non-class type ‘GameManager*’
main.cpp:11: error: request for member ‘handleEvents’ in ‘game’, which is of non-class type ‘GameManager*’
main.cpp:13: error: request for member ‘draw’ in ‘game’, which is of non-class type ‘GameManager*’
main.cpp:16: error: request for member ‘cleanup’ in ‘game’, which is of non-class type ‘GameManager*’
include/GameState.h:12: error: ‘GameManager’ has not been declared
include/GameState.h:13: error: ‘GameManager’ has not been declared
include/GameState.h:14: error: ‘GameManager’ has not been declared
include/GameState.h:15: error: ‘GameManager’ has not been declared
include/GameState.h: In member function ‘void GameState::changeState(int*, GameState*)’:
include/GameState.h:16: error: request for member ‘changeState’ in ‘* game’, which is of non-class type ‘int’
include/GameManager.h: At global scope:
include/GameManager.h:20: error: ISO C++ forbids declaration of ‘vector’ with no type
include/GameManager.h:20: error: expected ‘;’ before ‘<’ token
GameManager.cpp: In member function ‘void GameManager::cleanup()’:
GameManager.cpp:14: error: ‘states’ was not declared in this scope
GameManager.cpp: In member function ‘void GameManager::changeState(GameState*)’:
GameManager.cpp:25: error: ‘states’ was not declared in this scope
GameManager.cpp:31: error: ‘states’ was not declared in this scope
GameManager.cpp: In member function ‘void GameManager::pushState(GameState*)’:
GameManager.cpp:38: error: ‘states’ was not declared in this scope
GameManager.cpp:43: error: ‘states’ was not declared in this scope
GameManager.cpp: In member function ‘void GameManager::popState()’:
GameManager.cpp:50: error: ‘states’ was not declared in this scope
GameManager.cpp:56: error: ‘states’ was not declared in this scope
GameManager.cpp: In member function ‘void GameManager::handleEvents()’:
GameManager.cpp:65: error: ‘states’ was not declared in this scope
GameManager.cpp: In member function ‘void GameManager::update()’:
GameManager.cpp:71: error: ‘states’ was not declared in this scope
GameManager.cpp: In member function ‘void GameManager::draw()’:
GameManager.cpp:77: error: ‘states’ was not declared in this scope
include/GameState.h:12: error: ‘GameManager’ has not been declared
include/GameState.h:13: error: ‘GameManager’ has not been declared
include/GameState.h:14: error: ‘GameManager’ has not been declared
include/GameState.h:15: error: ‘GameManager’ has not been declared
include/GameState.h: In member function ‘void GameState::changeState(int*, GameState*)’:
include/GameState.h:16: error: request for member ‘changeState’ in ‘* game’, which is of non-class type ‘int’
include/GameManager.h: At global scope:
include/GameManager.h:20: error: ISO C++ forbids declaration of ‘vector’ with no type
include/GameManager.h:20: error: expected ‘;’ before ‘<’ token
include/IntroState.h:21: error: cannot declare variable ‘IntroState::m_IntroState’ to be of abstract type ‘IntroState’
include/IntroState.h:6: note: because the following virtual functions are pure within ‘IntroState’:
include/GameState.h:12: note: virtual void GameState::handleEvents(int*)
include/GameState.h:13: note: virtual void GameState::update(int*)
include/GameState.h:14: note: virtual void GameState::draw(int*)
include/MenuState.h:21: error: cannot declare variable ‘MenuState::m_MenuState’ to be of abstract type ‘MenuState’
include/MenuState.h:6: note: because the following virtual functions are pure within ‘MenuState’:
include/GameState.h:12: note: virtual void GameState::handleEvents(int*)
include/GameState.h:13: note: virtual void GameState::update(int*)
include/GameState.h:14: note: virtual void GameState::draw(int*)
IntroState.cpp:7: error: cannot declare variable ‘IntroState::m_IntroState’ to be of abstract type ‘IntroState’
include/IntroState.h:6: note: since type ‘IntroState’ has pure virtual functions
IntroState.cpp:24: error: no ‘void IntroState::pesume()’ member function declared in class ‘IntroState’
include/GameState.h:12: error: ‘GameManager’ has not been declared
include/GameState.h:13: error: ‘GameManager’ has not been declared
include/GameState.h:14: error: ‘GameManager’ has not been declared
include/GameState.h:15: error: ‘GameManager’ has not been declared
include/GameState.h: In member function ‘void GameState::changeState(int*, GameState*)’:
include/GameState.h:16: error: request for member ‘changeState’ in ‘* game’, which is of non-class type ‘int’
include/GameManager.h: At global scope:
include/GameManager.h:20: error: ISO C++ forbids declaration of ‘vector’ with no type
include/GameManager.h:20: error: expected ‘;’ before ‘<’ token
include/MenuState.h:21: error: cannot declare variable ‘MenuState::m_MenuState’ to be of abstract type ‘MenuState’
include/MenuState.h:6: note: because the following virtual functions are pure within ‘MenuState’:
include/GameState.h:12: note: virtual void GameState::handleEvents(int*)
include/GameState.h:13: note: virtual void GameState::update(int*)
include/GameState.h:14: note: virtual void GameState::draw(int*)
include/PlayState.h:21: error: cannot declare variable ‘PlayState::m_PlayState’ to be of abstract type ‘PlayState’
include/PlayState.h:6: note: because the following virtual functions are pure within ‘PlayState’:
include/GameState.h:12: note: virtual void GameState::handleEvents(int*)
include/GameState.h:13: note: virtual void GameState::update(int*)
include/GameState.h:14: note: virtual void GameState::draw(int*)
MenuState.cpp:7: error: cannot declare variable ‘MenuState::m_MenuState’ to be of abstract type ‘MenuState’
include/MenuState.h:6: note: since type ‘MenuState’ has pure virtual functions
include/GameState.h:12: error: ‘GameManager’ has not been declared
include/GameState.h:13: error: ‘GameManager’ has not been declared
include/GameState.h:14: error: ‘GameManager’ has not been declared
include/GameState.h:15: error: ‘GameManager’ has not been declared
include/GameState.h: In member function ‘void GameState::changeState(int*, GameState*)’:
include/GameState.h:16: error: request for member ‘changeState’ in ‘* game’, which is of non-class type ‘int’
include/GameManager.h: At global scope:
include/GameManager.h:20: error: ISO C++ forbids declaration of ‘vector’ with no type
include/GameManager.h:20: error: expected ‘;’ before ‘<’ token
include/PauseState.h:21: error: cannot declare variable ‘PauseState::m_PauseState’ to be of abstract type ‘PauseState’
include/PauseState.h:6: note: because the following virtual functions are pure within ‘PauseState’:
include/GameState.h:12: note: virtual void GameState::handleEvents(int*)
include/GameState.h:13: note: virtual void GameState::update(int*)
include/GameState.h:14: note: virtual void GameState::draw(int*)
include/PlayState.h:21: error: cannot declare variable ‘PlayState::m_PlayState’ to be of abstract type ‘PlayState’
include/PlayState.h:6: note: because the following virtual functions are pure within ‘PlayState’:
include/GameState.h:12: note: virtual void GameState::handleEvents(int*)
include/GameState.h:13: note: virtual void GameState::update(int*)
include/GameState.h:14: note: virtual void GameState::draw(int*)
PlayState.cpp:7: error: cannot declare variable ‘PlayState::m_PlayState’ to be of abstract type ‘PlayState’
include/PlayState.h:6: note: since type ‘PlayState’ has pure virtual functions
include/GameState.h:12: error: ‘GameManager’ has not been declared
include/GameState.h:13: error: ‘GameManager’ has not been declared
include/GameState.h:14: error: ‘GameManager’ has not been declared
include/GameState.h:15: error: ‘GameManager’ has not been declared
include/GameState.h: In member function ‘void GameState::changeState(int*, GameState*)’:
include/GameState.h:16: error: request for member ‘changeState’ in ‘* game’, which is of non-class type ‘int’
include/GameManager.h: At global scope:
include/GameManager.h:20: error: ISO C++ forbids declaration of ‘vector’ with no type
include/GameManager.h:20: error: expected ‘;’ before ‘<’ token
include/PauseState.h:21: error: cannot declare variable ‘PauseState::m_PauseState’ to be of abstract type ‘PauseState’
include/PauseState.h:6: note: because the following virtual functions are pure within ‘PauseState’:
include/GameState.h:12: note: virtual void GameState::handleEvents(int*)
include/GameState.h:13: note: virtual void GameState::update(int*)
include/GameState.h:14: note: virtual void GameState::draw(int*)
include/MenuState.h:21: error: cannot declare variable ‘MenuState::m_MenuState’ to be of abstract type ‘MenuState’
include/MenuState.h:6: note: because the following virtual functions are pure within ‘MenuState’:
include/GameState.h:12: note: virtual void GameState::handleEvents(int*)
include/GameState.h:13: note: virtual void GameState::update(int*)
include/GameState.h:14: note: virtual void GameState::draw(int*)
PauseState.cpp:7: error: cannot declare variable ‘PauseState::m_PauseState’ to be of abstract type ‘PauseState’
include/PauseState.h:6: note: since type ‘PauseState’ has pure virtual functions
make: *** [all] Error 1
Can anyone help?