Hi, I'm beginning my first game and was wondering how to implement seperate loops for in game, main menu etc. An idea I was trying to use is to have a base class 'CLoop' and then derive different classes for each type of loop (CGame, CMenu, etc.) In my main function I would make calls to the functions of the appropriate loop. I was hoping that something like this would work:
CLoop* currentloop = NULL;
CGame game;
CMenu menu;
...
currentloop = &menu; //makes 'menu' the active loop
...
currentloop->Draw(); // calls the menu's draw function
The problem is the call to Draw(); executes CLoop:raw(), despite the pointer pointing to an instance of CMenu, I assume because of the pointer being declared as type CLoop. So, is there any way I can declare a pointer independent of type, and have it point to any class? Hope this post makes sense.