#include<iostream>
using namespace std;
class Time
{
public:
Time(int h,int m,int s):hour(h),minute(m),second(s) {}
int hour;
int minute;
int second;
void get_time();
};
void Time::get_time()
{
cout<<hour<<":"<<minute<<":"<<second<<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; //指向Time类公用成员函数
(t1.*p3)();
return 0;
}
对象指针
最新推荐文章于 2024-04-06 17:11:35 发布