Let us see the example first.
#include <iostream> using namespace std; class A { public: A (int func(int, int)) { compare = func; } // give value void Test (int a, int b) { cout<<compare(a, b)<<endl; } // wrapper private: int (*compare) (int, int); // pointer of function }; int function (int a, int b) { return (a-b); } int main() { A a(function); a.Test(1,2); return 0; }
Obviously, we can see the pointer of function in the A class and give the value in the construction. Note the argument in the construction.