Hi I tried to introduce some inheritance to my game engine from the book SDL Game Development but I am getting a lot of errors. I am a real noob at c++ so I would appreciate a bit of detail about each error and what I can do to fix it, as far as I can tell the code is exactly the same as in the book on chapter 3 “Working with game objects” Please tell me what I am doing wrong to produce these errors and how I can fix them. Thanks.
g++ main.cpp -fpermissive -lSDL2 -lSDL2_image
In file included from main.cpp:7:0:
GameObject.h: In member function ‘void Player::draw()’:
GameObject.h:30:18: error: no matching function for call to ‘Player::draw()’
GameObject::draw()
^
GameObject.h:8:6: note: candidate: void GameObject::draw(SDL_Renderer*)
void draw(SDL_Renderer* pRenderer);
^~~~
GameObject.h:8:6: note: candidate expects 1 argument, 0 provided
In file included from main.cpp:8:0:
Player.h: At global scope:
Player.h:4:7: error: redefinition of ‘class Player’
class Player : public GameObject
^~~~~~
In file included from main.cpp:7:0:
GameObject.h:25:7: note: previous definition of ‘class Player’
class Player : public GameObject
^~~~~~
In file included from main.cpp:11:0:
Game.cpp: In member function ‘void Game::render()’:
Game.cpp:84:11: error: no matching function for call to ‘GameObject::draw()’
m_go.draw();
^
In file included from main.cpp:7:0:
GameObject.h:8:6: note: candidate: void GameObject::draw(SDL_Renderer*)
void draw(SDL_Renderer* pRenderer);
^~~~
GameObject.h:8:6: note: candidate expects 1 argument, 0 provided
In file included from main.cpp:11:0:
Game.cpp:86:26: error: no matching function for call to ‘Player::draw(SDL_Renderer*&)’
m_player.draw(m_pRenderer);
^
In file included from main.cpp:7:0:
GameObject.h:28:6: note: candidate: void Player::draw()
void draw()
^~~~
GameObject.h:28:6: note: candidate expects 0 arguments, 1 provided
In file included from main.cpp:13:0:
Player.cpp: At global scope:
Player.cpp:1:77: error: no ‘void Player::load(int, int, int, int, std::__cxx11::string)’ member function declared in class ‘Player’
void Player::load(int x, int y, int width, int height, std::string textureID)
^
Player.cpp:6:6: error: prototype for ‘void Player::draw(SDL_Renderer*)’ does not match any in class ‘Player’
void Player::draw(SDL_Renderer* pRenderer)
^~~~~~
In file included from main.cpp:7:0:
GameObject.h:28:6: error: candidate is: void Player::draw()
void draw()
^~~~