1. 在静态成员函数中调用静态成员函数指针,
例子如下
class CA;
typedef void (CA::*PFUN)();
STRUCT MSGMAP
{
UINT uMsg;
PFUN pFun;
};
CLASS CA
{
public:
CA();
static void Fun();
private:
static CA*p;
static MSGMAP MsgMap[];
};
CA* CA::p = NULL;
CA::CA()
{
p = this;
}
void CA::Fun()
{
for(int i = 0; WM_NULL != MsgMap[i].uMsg;i++)
{
(p->*(MsgMap[i].pFun))();
}
步骤省略了些, 主要是通过静态类指针 代替this来调用静态成员函数指针。