C++指向类成员函数的指针
时间:2011-06-05 来源:曾经白云飞
#include <iostream>
using std::cout;
using std::cin;
using std::cerr;
using std::endl;
class Obj
{
public:
double func(int p1, int p2)
{
return (p1+p2);
}
};
typedef double (Obj::* /*AS*/FcnPtrType/*(end of name)*/ )( int, int );
int main(int argc, char** argv)
{
double (Obj::* fontPtr)(int, int) = &Obj::func;
Obj obj;
cout << (obj.*fontPtr)(3, 7) << endl;
system("pause");
return 0;
}
相关阅读 更多 +