scopolamine

fig09_10.cpp

Mar 31st, 2011
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.37 KB | None | 0 0
  1. // Fig. 9.10: fig09_10.cpp
  2. // Demonstrating a default constructor for class Time.
  3. #include <iostream>
  4. #include "Time.h" // include definition of class Time from Time.h
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.    Time t1; // all arguments defaulted
  10.    Time t2( 2 ); // hour specified; minute and second defaulted
  11.    Time t3( 21, 34 ); // hour and minute specified; second defaulted
  12.    Time t4( 12, 25, 42 ); // hour, minute and second specified
  13.    Time t5( 27, 74, 99 ); // all bad values specified
  14. /*
  15.    cout << "Constructed with:\n\nt1: all arguments defaulted\n  ";
  16.    t1.printUniversal(); // 00:00:00
  17.    cout << "\n  ";
  18.    t1.printStandard(); // 12:00:00 AM
  19.  
  20.    cout << "\n\nt2: hour specified; minute and second defaulted\n  ";
  21.    t2.printUniversal(); // 02:00:00
  22.    cout << "\n  ";
  23.    t2.printStandard(); // 2:00:00 AM
  24.  
  25.    cout << "\n\nt3: hour and minute specified; second defaulted\n  ";
  26.    t3.printUniversal(); // 21:34:00
  27.    cout << "\n  ";
  28.    t3.printStandard(); // 9:34:00 PM
  29. */
  30.    cout << "\n\nt4: hour, minute and second specified\n  ";
  31.    t4.printUniversal(); // 12:25:42
  32.    cout << "\n  ";
  33.    t4.printStandard(); // 12:25:42 PM
  34.    t4.tickTime();
  35.  
  36. /*   cout << "\n\nt5: all invalid values specified\n  ";
  37.    t5.printUniversal(); // 00:00:00
  38.    cout << "\n  ";
  39.    t5.printStandard(); // 12:00:00 AM
  40.    cout << endl;
  41.    system("pause");
  42. */
  43. } // end main
Advertisement
Add Comment
Please, Sign In to add comment