Source of testime5.cpp


  1: // Filenme: TESTIME5.CPP
  2: // Purpose: Illustrates a simple time class, with two constructors
  3: //          three accessor functions, a friend function, and four
  4: //          overloaded operators.

  6: #include <iostream>
  7: #include <fstream>
  8: #include <stdlib>
  9: #include "TIME5.H"
 10: #include "PAUSE_CPP"


 13: int main()
 14: {
 15:     cout << endl
 16:          << "This program illustrates the use "
 17:          << "of a simple time class. "            << endl
 18:          << "You should study the source code "
 19:          << "at the same time as the output. "    << endl
 20:          << endl;

 22:     TimeType t0;
 23:     TimeType t1(11, 59, 50);
 24:     TimeType t2(12);
 25:     cout << t0;  cout << endl;
 26:     cout << t1;  cout << endl;
 27:     cout << t2;  cout << endl;
 28:     Pause(); cout << endl;

 30:     while (t1 < t2)
 31:     {
 32:         cout << t1;  cout << endl;
 33:         t1.Increment();
 34:     }
 35:     if (t1 == t2) cout << endl << t1 << "  " << t2 << endl;
 36:     Pause();  cout << endl;

 38:     TimeType t3(12, 20, 32);
 39:     TimeType t4(15, 47, 56);
 40:     TimeType t5;
 41:     t5 = t3 + t4;
 42:     cout << t3;  cout << endl;
 43:     cout << t4;  cout << endl;
 44:     cout << t5;  cout << endl;
 45:     Pause();  cout << endl;

 47:     system("dir");  // The program makes a "system call".
 48:     Pause();  cout << endl;
 49:     ofstream outFile("ttt.tmp");
 50:     outFile << t1 << endl << t4 << endl << t5 << endl;
 51:     outFile.close();
 52:     system("dir");
 53:     Pause();  cout << endl;
 54:     system("type ttt.tmp");  // Another "system call"
 55:     Pause();  cout << endl;

 57:     return 0;
 58: }