I'm reading the book SDL Game Development. And where going to do this step. And then I'm got stuck my compiler complained about that Game::Game() was undefined? And I'm not really sure what's wrong?
I know that I have both main.cpp and Game.h in the same directory so it cannot be that, that is wrong.
What does a "undefined reference" error even mean?
The main.cpp file
Code:
#include <iostream>
#include "SDL.h"
#include "Game.h"
using namespace std;
Game *g_game = 0;
int main(int argc, char* argv[])
{
g_game = new Game();
return 0;
}
The Game.h file
Code:
#ifndef GAME_H_INCLUDED
#define GAME_H_INCLUDED
class Game
{
public:
Game();
~Game();
// Initialize
void init() {m_bRunning = true;}
void render() {}
void update() {}
void handleEvents() {}
// To access the private running variable
bool running() {return m_bRunning;}
private:
bool m_bRunning;
};
#endif // GAME_H_INCLUDED