Original Post
Hello, I am trying to grasp function pointers, particularly to use as callbacks in my GUI. Can anyone explain what I have done wrong here, when trying to pass a function pointer? I think I am close!
class cTimer
{
public:
cTimer();
void SetCallback( void (*ptrTimeOut)( void ) );
void Start( float target );
bool Update( void );
void (*ptrTimeOut)( void );
// void (cTimer::*ptrTimeOut)( void );
// inline void TimeOut( void ) { (*this.*ptrTimeOut)(); }
protected:
float m_time;
float m_target;
};
// Then in my main class, cSimulationLayer
void cSimulationLayer::NextStage()
{
m_stage++;
}
void cSimulationLayer::Init()
{
m_timer = new cTimer();
m_timer->SetCallback ( cSimulationLayer::*NextStage() );
// or.....
m_timer->SetCallback ( &(cSimulationLayer::NextStage()) );
}