C++类成员的函数指针

#include <iostream>
using namespace std;
class TTest
{
public:
void (TTest::*pfun)(void);

void test();

void fun(void);
};

void TTest::fun()
{
cout << "TTest::fun()" << endl;
}

void TTest::test()
{
pfun = &TTest::fun;
(this->*pfun)();

}

int main()
{
TTest* t=new TTest();
t->fun();
t->test();
delete t;

int wait;
cin >> wait;
return 0;
}

posted @ 2013-07-06 12:39  Predator  阅读(155)  评论(0编辑  收藏  举报