class A
{
public:
A (){}; /* constructor */
void func(){}
}; /* ----- end of class A ----- */
typedef void (A::*FUNC)(); // define a function pointer type
int main(void){
A a;
FUNC p = &A::func;
(a.*p)(); // must write with this style to call this fuction pointer
}
本文介绍如何在C++中定义类、构造函数、成员函数,并通过函数指针调用类的成员函数。
514

被折叠的 条评论
为什么被折叠?



