2008年7月2日星期三

point to member function 成员函数指针

class CA
{
public:
CA(void (*pfn)(int));
};

class CB
{
public:
CB()
{
CA a(&Fx1);
};
public:
void Fx1(int)
{};
};
/////////////
error C2276: '&' : illegal operation on bound member function expression

solution:

class CA;

class CB
{
public:
CB(void (CA::*)()){};
};


class CA
{
public:
CA()
{
CB b(&CA::Fx);
};
void Fx();
};

没有评论: