CSC 271
Homework 7 in C++

Assigned Nov 10, due Nov 22

For the following programming problems, be sure your classes have exactly the interface I specify; I'll be testing them by linking them together with my own main function, and if they don't match up, it'll be extra work for me, which makes me cranky just at the time that I'm grading your homework :-)

Every class should have a static test function which runs a bunch of test cases on the other functions and reports whether they all produced the expected results. You'll presumably test these things by writing a main function that calls the various test functions.

Follow the usual C++ conventions with regard to header files, getter names, etc.

Keep efficiency and memory safety in mind. For example, if you're returning a large object, decide whether to return a pointer, return a whole object, or return a const reference. Make sure accessor functions are marked as such, so the compiler can optimize them and they can be called on const objects. Watch out for memory leaks and dangling pointers/references. And so on.

  1. Define a class Date with integer fields for day-of-month, month, and year. Write the following member functions:

    Some other things to try for extra credit:
  2. Define a class RunnerLog to represent an entry in a runner's log book. It should have fields for the date of the run (a Date), how many miles (double), how many hours (double), and a free-form comment field (string). Write the following member functions:


  3. Last modified: 
    Stephen Bloch / bloch@adelphi.edu