用类来实现时间输入输出
#includeusing namespace std;class Time{ public: int hour; int minute; int sec;};void set_time(Time&t){ cin>>t.hour; cin>>t.minute; cin>>t.sec;}void show_time(Time&t){ cout< <<":"< <<":"< <
实参声明
#includeusing namespace std;class Time{ public: int hour; int minute; int sec;};void set_time(Time&t,int hour,int minute,int sec){ t.hour=hour; t.minute=minute; t.sec=sec;}void show_time(Time&t){ cout< <<":"< <<":"< <
标准类的方法
#includeusing namespace std;class Time{ private: int hour; int minute; int sec; public: void set_time(){ cin>>hour; cin>>minute;m cin>>sec; } void show_time(){ cout< <<":"< <<":"< <