- 论坛徽章:
- 0
|
原帖由 namtso 于 2006-11-14 10:36 发表
类型不匹配。
void (*p)(int)
void (A::*p)(int)
注意类成员函数的“类属属性”。
可是我改成下面这样怎么编译有错误呢?
#include<iostream>
//#include<vector>
#include<cmath>
using namespace std;
class A{
private:
typedef void (A::*p)(int i);
p pp;
public:
void print(int i){
cout<<i<<endl;
}
A()
{
}
void test()
{
this->pp=print;
pp(4);
}
};
int main()
{
return 0;
}
编译提示:
Compiling...
test.cpp
C:\Documents and Settings\administrator.NEUSOFT-CUICP\桌面\test.cpp(20) : error C2064: term does not evaluate to a function
Error executing cl.exe.
test.exe - 1 error(s), 0 warning(s)
谢谢!! |
|