usetime2.cpp 873 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // usetime2.cpp -- using the third draft of the Time class
  2. // compile usetime2.cpp and mytime2.cpp together
  3. #include <iostream>
  4. #include "mytime2.h"
  5. int main()
  6. {
  7. using std::cout;
  8. using std::endl;
  9. Time weeding(4, 35);
  10. Time waxing(2, 47);
  11. Time total;
  12. Time diff;
  13. Time adjusted;
  14. cout << "weeding time = ";
  15. weeding.Show();
  16. cout << endl;
  17. cout << "waxing time = ";
  18. waxing.Show();
  19. cout << endl;
  20. cout << "total work time = ";
  21. total = weeding + waxing; // use operator+()
  22. total.Show();
  23. cout << endl;
  24. diff = weeding - waxing; // use operator-()
  25. cout << "weeding time - waxing time = ";
  26. diff.Show();
  27. cout << endl;
  28. adjusted = total * 1.5; // use operator+()
  29. cout << "adjusted work time = ";
  30. adjusted.Show();
  31. cout << endl;
  32. // std::cin.get();
  33. return 0;
  34. }