引用多个对象的成员

 1 #include <iostream>
 2 
 3 /* run this program using the console pauser or add your own getch, system("pause") or input loop */
 4 using namespace std;
 5 class Time
 6 {
 7     public:
 8         int hour;
 9         int minute;
10         int sec;
11 };
12 
13 int main(int argc, char** argv) {
14     Time t1;
15     cin>>t1.hour;
16     cin>>t1.minute;
17     cin>>t1.sec;
18     cout<<t1.hour<<":"<<t1.minute<<":"<<t1.sec<<endl;
19     
20     Time t2;
21     cin>>t2.hour;
22     cin>>t2.minute;
23     cin>>t2.sec;
24     cout<<t2.hour<<":"<<t2.minute<<":"<<t2.sec<<endl;
25     return 0;
26 }

 

posted @ 2018-08-01 16:09  borter  阅读(115)  评论(0编辑  收藏  举报