#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;
}

 

相关文章:

  • 2021-10-01
  • 2022-12-23
  • 2021-07-07
  • 2021-11-21
  • 2022-12-23
  • 2021-10-08
  • 2021-06-25
猜你喜欢
  • 2021-11-21
  • 2021-11-16
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-03
  • 2021-06-07
相关资源
相似解决方案