Hit a brick wall now...
Starting to get issues passing objects declared in other classes to a namespace.
I got objects of the Player and Timer classes defined in the global space of main.cpp , in game.h I have :
namespace K_GAME
{
extern Player *ptr_mPlayer;
extern Timer *ptr_mDelta;
function prototypes ...
}
in game.cpp:
namespace K_GAME
{
Player *ptr_mPlayer = NULL;
Timer *ptr_mDelta = NULL;
}
void K_GAME::init_game( Player &mPlayer, Timer &mDelta )
{
*ptr_mPlayer = mPlayer;
*ptr_mDelta = mDelta;
ptr_mPlayer->set_player( 400, 500 );
}
The idea was to make the pointers and then assign the pointers to the objects passed to init_game, the code compiles and links fine but spits out a access violation error at runtime
First-chance exception at 0x00f2245c in kickstick.exe: 0xC0000005: Access violation writing location 0x00000000.
Unhandled exception at 0x00f2245c in kickstick.exe: 0xC0000005: Access violation writing location 0x00000000.
Seems that the address of the objects is not being passed to the ptr pointers for some reason.
If it relevant it was suspicious I had to use forward declaration of both Timer and Player classes to get the code to work, its suspicious as game.h includes IO.h which includes both Timer.h and Player.h.
I would of thought that as IO.h has the definition of Timer and Player it wouldnt need forward declarations.
Thanks for reading