• 请问为什么会报错error:cannot call member fu
  • 测试技术
    2.00元

#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

  • vicky    2020-05-14 10:19:22
  • 阅读 918    收藏 0    回答 1
  • 邀请
  • 收藏
  • 分享
发送
登录 后发表评论
  • 51testing软件测试圈微信