The C++Course provides a general introduction to programming in C++. It is based on A.B. Downey's book, How to Think Like a Computer Scientist. Click here for details.


Printtime

When we define a new type it is a good idea to write function that displays the instance variables in a human-readable form. For example:

void printTime (Time& t) {
  cout << t.hour << ":" << t.minute << ":" << t.second << endl;
}

The output of this function, if we pass time an argument, is 11:59:3.14159.


Last Update: 2005-12-05