#include <iostream>
using namespace std;
class Time{
public:
Time(int,int,int);
int hour;
int minute;
int sec;
void get_time();
};
void Time::get_time(){
cout<<hour<<":"<<minute<<":"<<sec<<endl;
}
int main(){
Time t1(10,13,56);
int *p1=&t1.hour;
cout<<*p1<<endl;
t1.get_time();
Time *p2=&t1;
p2->get_time();
void (Time::*p3)();
p3=&Time::get_time();//就是这里报的错
(t1.*p3)();
return 0;
}
求解答,请问为什么会报错error:cannot call member function 'void Time::get_time()'without object
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
1条回答 默认 最新
- threenewbee 2020-05-13 21:43关注
p3=&Time::get_time;
不要括号本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 5无用 2
悬赏问题
- ¥50 汇编语言除法溢出问题
- ¥65 C++实现删除N个数据列表共有的元素
- ¥15 Visual Studio问题
- ¥15 state显示变量是字符串形式,但是仍然红色,无法引用,并显示类型不匹配
- ¥20 求一个html代码,有偿
- ¥100 关于使用MATLAB中copularnd函数的问题
- ¥20 在虚拟机的pycharm上
- ¥15 jupyterthemes 设置完毕后没有效果
- ¥15 matlab图像高斯低通滤波
- ¥15 针对曲面部件的制孔路径规划,大家有什么思路吗