I'm coding a game engine and I'm trying to make all it's functions sorta hidden and mostly rule-free so when programmers code the game, they don't bother with how or why something needs to be that way or another, and I'm trying to stick to leave it purely as C++ language.
So, for example, I don't want them to:
//Going to create a new object on screen
Object* newObject = gameEngine.gameModels.NewObject(); //I don't want this
Instead, I want them to be able to do this:
//Going to create a new object on screen
Object* newObject = new Object();
newObject->Load("objectName"); //Done!
But for this to work, I need to keep the address of my resource loader so I can call the proper Load function and do the actual loading, and this is what I'm doing:
class BaseModel
{
friend GameEngine;
private:
static ResourceModule* moduleAddress;
};
class Model : public BaseModel
{
public:
void Load(char* assetName)
{
//use moduleAddress as needed
};
};
class GameEngine
{
public:
void Initialize()
{
myBaseModel.moduleAddress = &myResourceModule;
}
private:
ResourceModule myResourceModule;
BaseModel myBaseModel;
};
But I'm getting an unresolved external error for the "static ResourceModule* resourceModuleAddress" line, and I can't get the "friend" keyword to work (it also says the variable is private and can't be accessed).
Any suggestions on how can I accomplish what I'm trying to do, or how can I get this code above working?