using namespace std;
class MyTpl{
public:
virtual ~MyTpl(){};
virtual void Run(){};
protected:
MyTpl(){};
};
template<class T>
class Cb:public MyTpl{
private:
typedef void (T::*Done)();
Done run_;
T* obj_;
public:
Cb(T* obj,Done run):
obj_(obj),run_(run){}
void Run(){
(obj_->*run_)();
}
};
class Test{
public:
void Run0(){
printf("%s\r\n",__FUNCTION__);
}
};
template<class T>
MyTpl* NewCb(T* obj,void (T::*member)())
{
return new Cb<T>(obj,member);
}
int main()
{
Test test;
MyTpl *mytpl = NewCb(&test,&Test::Run0);
mytpl->Run();
return 0;
}