#include<iostream>
using namespace std;
class Time
{public:
void set_time();
void show_time();
private:
int hour;
int minute;
int sec;
};
Time t;
int main()
{t.set_time();
t.show_time();
return 0;}
void Time::set_time()
{cin>>t.hour;
cin>>t.minute;
cin>>t.sec;}
void Time::show_time()
{cout<<t.hour<<":"<<t.minute<<":"<<t.sec<<endl;}
这个里面最后两个定义类中的函数中为什么都是用的“t.hour,t.minute,sec”?上面“Timet”语句应该只是定义t是一个Time类的对象吧??
using namespace std;
class Time
{public:
void set_time();
void show_time();
private:
int hour;
int minute;
int sec;
};
Time t;
int main()
{t.set_time();
t.show_time();
return 0;}
void Time::set_time()
{cin>>t.hour;
cin>>t.minute;
cin>>t.sec;}
void Time::show_time()
{cout<<t.hour<<":"<<t.minute<<":"<<t.sec<<endl;}
这个里面最后两个定义类中的函数中为什么都是用的“t.hour,t.minute,sec”?上面“Timet”语句应该只是定义t是一个Time类的对象吧??