下载此文档

马钢钢板质保书.doc


文档分类:建筑/环境 | 页数:约3页 举报非法文档有奖
1/3
下载提示
  • 1.该资料是网友上传的,本站提供全文预览,预览什么样,下载就什么样。
  • 2.下载该文档所得收入归上传者、原创者。
  • 3.下载的文档,不会出现我们的网址水印。
1/3 下载此文档
文档列表 文档介绍
Chapter 13
Operator overloading
Simple Time class
Time
- hour: int
- min: int
+Time( )‏
+Time(hr: int, mn: int)‏
+equals( tm: Time): bool
+lessThan( tm: Time): bool
+ print( )‏
+setHour(hr: int)‏
+setMin(mn: int)‏
Holds hours and minutes
prints as : HH:MM
Could be used like this....
// in main
Time currentTime(hr, mn);
const Time LUNCH_TIME( 11, 30 ); // use 2 parameter constructor
cout << "Lunch time: ";
( cout );
cout << endl;
while( ( LUNCH_TIME ) ) { // loop until time to eat
cout << "Clock: ";
( cout );
cout << endl;
........ // other code
( getHourFromSystemClock( ) ) ;
( getMinuteFromSystemClock( ) ) ;
}
cout << "Class is Over: Time to go eat \n";

But we would like to make it more normal
// in main
Time currentTime(hr, mn);
const Time LUNCH_TIME( 11, 30 ); // use 2 parameter constructor
cout << "Lunch time: ";
( cout );
cout << endl;
while( ( LUNCH_TIME ) ) { // loop until time to eat
cout << "Clock: ";
( cout );
cout << endl;
........ // other code
( getHourFromSystemClock( ) ) ;
( getMinuteFromSystemClock( ) ) ;
}
cout << "Class is Over: Time to go eat \n";

Making Time more normal....
// in main
Time currentTime; // use default cons

马钢钢板质保书 来自淘豆网www.taodocs.com转载请标明出处.

非法内容举报中心
文档信息
  • 页数3
  • 收藏数0 收藏
  • 顶次数0
  • 上传人zxwziyou8
  • 文件大小425 KB
  • 时间2018-07-05
最近更新