Original Post
There seems to be alot of different solutions for implementing a callback in C++ from templates to std::tr1. I think the latter is the standard these days.
I have been searching around for a simple example that will work for me. Coming from a C# background it's a little daunting trying to find a simple solution.
I have a Transition class that I want to be able to set a callback in another class that will be called when the transition has changed state (Eg. Finished). It needs one parameter (an integer)
During the Update() call in certain circumstances I need to call the callback.
I have been searching around for a simple example that will work for me. Coming from a C# background it's a little daunting trying to find a simple solution.
I have a Transition class that I want to be able to set a callback in another class that will be called when the transition has changed state (Eg. Finished). It needs one parameter (an integer)
class Transition {public: Transition(); ~Transition(); void SetCallback(...) { ... } void Update(); private: ... *m_callback;};During the Update() call in certain circumstances I need to call the callback.
void Transition::Update(){ ... if(m_callback != NULL) m_callback(0);}