I have a class called "Game", with prototypes functions "Update" and "Draw" but they're not defined. It's up to the object inheriting the "Game" object to override them. Is this possible?
Contents of "Game.h"
class Game // does it have to abstract/virtual?
{
public:
//General stuff for all games here
}
void Update(Game *game) = 0; // or make it virtual in someway
Contents of "MyGame.h"
#include "Game.h"
class MyGame : public Game
{
public:
// General stuff for my game
}
void Update(MyGame *game);
// Contents of "MyGame.cpp"
#include "MyGame.h"
void Update(MyGame *game) // does it have to be overriden/overloaded?
{
}
// Contents of "GameManager.h"
#include "Game.h"
class GameManager
{
public:
Game *game;
}
void Update(GameManager *manager);
// Contents of "GameManager.cpp"
#include "Game.h"
void Update(GameManager *manager)
{
Update(manager->game);
}
The key is the last method: Why can't GameManager call MyGame Update() method when GameManager's Game object = MyGame and not Game?