///对象指针
#include <iostream>
using namespace std;
class Time {
public:
Time(int h=10,int m=10,int s=10):hour(h),minute(m),sec(s) {}
int hour;
int minute;
int sec;
void get_time();
};
void Time::get_time() {
cout<<hour<<" "<<minute<<" "<<sec<<endl;
}
int main() {
Time t(12,13,14);
int *p=&t.hour; ///指向对象数据成员的指针(公有的)
cout<<*p<<endl;
Time *p1; ///指向对象的指针
p1=&t;
p1->get_time();
/*
///指向普通函数的指针写法
void (*p)();
p=fun();
(*p)();
*/
///指向对象,成员函数的指针
void (Time::*p2)();
p2=&Time::get_time;
(t.*p2)();
return 0;
}