Description
Write a C++ program to include the following additional member functions in your
class from the previous computer assignment:
This is a copy constructor that can be used to create a
new object from the copy of the object
This is a assignment operator that
overwrites an existing object with the copy of the object
This function can be used to add number of
days to a object.
This function can be used to add number
of months to a object. If the day of the resulting month is larger than the
number of days in that month, then choose the following month with
This function can be used to add number of
years to a object.
This public function returns an index value for a object,
which is simply equal to the number of days passed from the reference date of
with the index value This implies that the index values for days
after this date have positive values and the index values for days before this
date have negative values. For example, the index value for is
and the index value for is because there is no year
This function returns the index value of a month from
the vector, which is between and and the returned index value
can be used to get the month of a object.
You also need to have the non-member function:
to get the number of days between the and Remember that the
difference between the years and is not When you move from a date with a
positive index value to a year with a negative index value or vice versa, you need to
consider this fact in your computation.
A driver program is supplied to test your class. The source file of the driver program
is To use this source file, make a link from your program directory. To compile
the source files and and link their object files with the system library
routines, make a link to the from your program directory and then execute:
To test your program, execute: The files and the
2
are located in directory: The correct output file is also
located in the same directory.
The routine tests the member functions of the class for several given dates.
For each object it calls the non-member function
This routine checks if is a valid date, and if it’s not, it prints an error message on
and it returns otherwise, it prints on and it returns
When your program is ready, mail its source and header files of your class to your
TA by executing: