I am writing a wrapper for a multithreaded scheme. It should operate similar to a timer.
I have a particular class (clock) that implements a function called tick which should be passed to constructor. How do I describe a C++ style function (myClass::myfunction, as opposed to the C convention) as the parameter to a method or constructor?
Would anybody be kind enough to show me the declaration for this kind of constructor?
clock myInstance(otherClass::aMethod)
myInstance.tick(); // Should call otherClass::aMethod
myInstance.tick();
Does C++11 and Bind help?
You can either call a static member function of a class or a non-static member function of an object. A non-static member function needs to have the context of an object (
thispointer).Here’s a simplified example of how you can use functors and bind to call a member function.