C++ Language/Std/Stl/CallableObjects/MemberFunction

From Wikibooks, open books for an open world
Jump to navigation Jump to search

A callable-object could also be assigned to a C++ member function:
std::function<int(const CRType*,int,int)> DoMath 
  = &CRType::DoAddition;
Now, invocation requires both parameters and a this pointer (an address of some pre-existing target-object): DoMath(&oTargetObject, 11, 22).

Additional information about a member function being a callable-object (includes interactive examples)