#include <iostream> #include <windows.h> #include <string> using namespace std; typedef void ( *tFunc )( void ); class subclass{ public: virtual tFunc setFun() = 0; }; #define __SetCallBack1(op_name,wrapper_name) class op_name:public subclass{ public: op_name(tFunc func):mfunc(func){} tFunc setFun(){return mfunc;} tFunc mfunc; }; inline op_name wrapper_name(tFunc func){return op_name(func);} #define _SetCallBack1(name) __SetCallBack1(name##T,name) _SetCallBack1(SetInitFunc) template<class OP1> void InitControl( OP1 op1) { subclass *msc=&op1; tFunc f = msc->setFun(); f(); } void printss() { cout<<"hello"<<endl; } int main() { InitControl(SetInitFunc(printss)); cin.get(); return 0; }