The compiler will create a binary object file from a source file. The idea is to let the header file be a sort of catalogue for your class/library for the program to use. So, in your case (I guess: I haven't read the entire thread)
Code:
//GameManager.h
#ifndef GAMEMANAGER_H
#define GAMEMANAGER_H
struct GameManager
{
GameManager(); //Just the name of the function, and its arguments.
};
//don't forget the endif
#endif
Then...
Code:
//GameManager.cpp
#include "GameManager.h"
//This is where your compiler is going to look, after seeing your stuff declared in the .h
GameManager::GameManager() : money(200) /*initializers, etc...*/
{
//empty
}
Now, source files that want to use GameManager will include GameManager.h . For each function call regarding GameManager (unless your compiler recognizes inline possibilities), the system will jump to the definition in your program file, and run it, and then go back. If, instead, you want the function code to be reiterated (expanded on spot) where it is called, you can make a request to the compiler to do so with inline.
Say you had a function GameManager::small_task(). You would declare it as you have been:
Code:
//GameManager.h
#ifndef GAMEMANAGER_H
#define GAMEMANAGER_H
struct GameManager
{
GameManager();
void small_task(); //Note how I still am not writing the function code here
};
//don't forget the endif
#endif
And then
Code:
//GameManager.cpp
#include "GameManager.h"
inline void GameManager::small_task()
{
std::cout << "My! This is such a small task. I wish I could avoid the overhead of a function call...." << std::endl;
}
GameManager::GameManager() : money(200) /*initializers, etc...*/
{
//empty
}
So that's how that works. Now, if you go ahead and write the definition (body code) of the function in the header file, then that is equivalent to doing the inline I just did. The method involving inline, however, is often preferred.