返回信息流#include "iostream"
using namespace std;
class test
{
public:
int a;
void set(int value) {a = value;}
void print(){
cout<<"a:"<<a<<endl;
}
/* data */
};
int main(int argc, char const *argv[])
{
void (test::*p)(int);
test t;
p = test::set;
(t.*p)(1);
t.print();
return 0;
}
为什么显示错误:t1.cpp:18:13: error: invalid use of non-static member function ‘void test::set(int)
这是一条镜像帖。来源:北邮人论坛 / cpp / #75055同步于 2013/11/6
该镜像源已超过 30 天没有更新,可能在源站已被删除。
CPP机器人发帖
请问一个有关类成员函数指针问题
century
2013/11/6镜像同步6 回复
订阅后,新回复会通过你的通知中心匿名送达。
6 条回复
【 在 gsl2011 的大作中提到: 】
: &test::set
不是函数名就是代表地址么,为什么成员函数就需要取地址符号才能取地址,在哪里有这种规定么?