Pointer to Function for Phase Management
-
Greetings, I would like to write a generic CPhaseManagement object, but keep hitting a wall with it being tied to the specific app. The Phases would be something like: InitPhase, IntroPhase, MenuPhase, AppPhase, and ExitPhase with an enumerated type defined in a PhaseSettings.h file ! Each Phase of the App will have it's own specific Phase routines (StartPhase, ProcessPhase and ExitPhase). These of course will be App specific. So I need to know how to make a pointer to a function so that the PhaseManager can call the relevant PhaseStart/exit etc. Any pointers (haha) / comments appreciated. If sex is a pain in the ass, then you are doing it wrong!
-
Greetings, I would like to write a generic CPhaseManagement object, but keep hitting a wall with it being tied to the specific app. The Phases would be something like: InitPhase, IntroPhase, MenuPhase, AppPhase, and ExitPhase with an enumerated type defined in a PhaseSettings.h file ! Each Phase of the App will have it's own specific Phase routines (StartPhase, ProcessPhase and ExitPhase). These of course will be App specific. So I need to know how to make a pointer to a function so that the PhaseManager can call the relevant PhaseStart/exit etc. Any pointers (haha) / comments appreciated. If sex is a pain in the ass, then you are doing it wrong!
int Foo1( WPARAM, LPARAM )
{
}int Foo2( WPARAM, LPARAM )
{
}int (*pFunc)( WPARAM, LPARAM );
if (some_condition)
pFunc = Foo1;
else if (some_other_condition)
pFunc = Foo2;(*pFunc)(parameter_list);
Five birds are sitting on a fence. Three of them decide to fly off. How many are left?
-
int Foo1( WPARAM, LPARAM )
{
}int Foo2( WPARAM, LPARAM )
{
}int (*pFunc)( WPARAM, LPARAM );
if (some_condition)
pFunc = Foo1;
else if (some_other_condition)
pFunc = Foo2;(*pFunc)(parameter_list);
Five birds are sitting on a fence. Three of them decide to fly off. How many are left?
cast to pointer to Function hey ! Who would have thought! (Obviously not me) Much Appreciated If sex is a pain in the ass, then you are doing it wrong!
-
cast to pointer to Function hey ! Who would have thought! (Obviously not me) Much Appreciated If sex is a pain in the ass, then you are doing it wrong!
Does this mean that I have to create a pointer to a ? As opposed to a pointer to a function with any set of params. Obviously when I call it, I will have to pass the right param types, but do I have to declare the pointer to have those param types ? Or am I flogging a dead camel ? If sex is a pain in the ass, then you are doing it wrong!