I have a header like this (header guards not shown):
class GameSystem
{
public:
GameSystem(Game *pcGame);
virtual ~GameSystem();
void Setup();
private:
void InitGame();
void RunGame();
void ExitGame();
Game *m_pcGame;
/* Properties */
int m_nWidth;
int m_nHeight;
int m_nFps;
bool m_bFullscreen;
};
Where can I define the body for InitGame(), RunGame() and ExitGame()? Can I define it in my .cpp file? If so, how? Or am I obliged to make their body in my .h file?
I’m using Eclipse and I began typing: void GameSystem:: and then it doesn’t suggest the private functions.
Yes, you can define then in a .cpp file. Just put
#include "MyHeader.h"at the beginning of the file. You’ll also need to start each function like so