   Inheritance: Can 'Base' class start a function that 'Inherited' finishes?
  I've got a situation where most of the functions in my various game states need to access a pointer to the Game itself. Up until now I've just been having a game pointer passed as an argument in each function. void Init(CGame* game);void Cleanup();void Input(CGame* game);void Update(CGame* game);void Draw(CGame* game);...void AddImage(CGame* game, char* path, int destX, int destY, int srcX, int srcY,  int width, int height, bool alpha);It works but as I started adding more functions I realized I don't want to pass the game every single time. I decided to have a member of the gamestate class that is just a pointer to a game (CGameState::m_Game), set up in the Init() function like this (CStTitleScreen is derived from CGameState):void CStTitleScreen::Init(CGame* game){  m_Game = game;  ...}The problem is I don't want to type "m_Game = game;" in every state that I create. Is it possible to set m_Game = game; in CGameState::Init and then CONTINUE the function in the derived init function?I hope what I'm asking makes sense. Right now CGameState has a pure virtual function: virtual void Init(CGame* game) = 0; which makes me think I can't implement "part of it" in the base class.   
  If you have only one instance of game for any state, consider making the pointer to it a static one. Then initialize it once.class CGameState{  private:static CGame* m_pGame;  public:static void Game(CGame* game) { m_pGame = game; }}class SomeState : public CGameState{}void InitApplication(CGame* game){  CGameState::Game(game); // Just once};  I'm not sure if I understand correctly (it's not you, it's me), but is this what you want?struct base {    virtual void do_stuff(char *data); // the base does some stuff first};void base::do_stuff(char *data) {    cout << "The base is doing stuff with this data:\n"; // so it's base first    cout << data;    cout << "\n\n";}struct derived: public base {    virtual void do_stuff(char *data) {   // now, you CAN call the base class's   // version of the same function, and   // then you can continue with yours.   // you can call it anywhere, but if   // you want it to be done first:   base::do_stuff(data); // should do the base's stuff first   // now, as you want it, continue!   cout << "Derived's version now continues...";    }};derived d;d.do_stuff("hello");// should output// The base is doing stuff with this data:// hello////// Derived's version now continues...;  Here is another way of doing what the last user did:class Base {protected:virtual void Init() = 0;// This gets over-riddenpublic:void Initialize() {// Do whatever must be done with each objectInit();// Call the over-ridden derived Init function}};class Derived : public Base {private:virtual void Init() {// Do Derived's Init} };The user calls the Initialize function and the common stuff is done before calling the over-ridden Init function.  I believe there is a name for this pattern but can't remember what it is called.Hope this is what you are looking for.vbuser   ;  It's called the Nonvirtual Interface pattern (NVI), although it's more common to make the base class virtual function private rather than protected since it will should only ever be called from the base class.Σnigma   ;  These are all valid ways of dealing with the problem as stated.However, the function name "Init" (case-insensitive) is always a big red warning flag to me. Why aren't you doing this stuff in the constructor instead? Then, when you write the derived constructors, you can just pass the Game* argument to the base constructor in the initializer list:// BTW, please don't use those C prefixes on your class names. What problem are// you really hoping they will help solve? What might you confuse the name with?class Base {  Game* game;  public:  Base(Game* game) : game(game) {    // rest of init() stuff here  }  // Similarly, "Cleanup" sounds like it does the work of the destructor:  ~Base() {    // Cleanup() stuff here   }  // If you have any other virtual functions, you should normally make the  // destructor virtual too: as, "virtual ~Base()".  // other functions use the game member as needed};class Derived: public Base {  // Because we provided a Base constructor, the "default no-arg constructor"  // is not provided. Thus there is no way to default-construct a Base, since  // we didn't provide our own no-arg constructor. This is a Good Thing; there  // is no meaningful such construction.  // It also *forces* us to use the initializer list, as shown:  public:  Derived(Game* game): Base(game) {}};;  I'd second Enigma's use of the NVI pattern. We use it with success to crudely implement Eiffel's pre/post conditions.CheersChris   