类和对象的简单应用

 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 
 6 class Time
 7 {
 8     public:
 9         int hour;
10         int minute;
11         int sec;
12 };
13 
14 int main(int argc, char** argv) {
15     Time t1;
16     cin>>t1.hour;
17     cin>>t1.minute;
18     cin>>t1.sec;
19     cout<<t1.hour<<":"<<t1.minute<<":"<<t1.sec<<endl;
20     return 0;
21 }

猜你喜欢

转载自www.cnblogs.com/borter/p/9401834.html