Question: Using C++ A struct (or object) to represent dates is to be implemented. It must contain a string for the day of the week, and

Using C++

A struct (or object) to represent dates is to be implemented. It must contain a string for the day of the week, and three numbers for the day of the month, the month, and the year.

Part A. Give the struct definition, along with a suitable set function for initialising a date, and a print function that prints one nicely. Using your definitions, I should be able to write this:

date today, st_swithins_day;

set(today, Tuesday, 22, 11, 2011); set(st_swithins_day, Friday, 15, 7, 2011); print(today);

and when run, that code should print something very close to this

Tuesday 22nd November 2011

or this

Tuesday November 22nd 2011

Part B. Define a function called latest, which takes two dates as parameters, and returns as its result the one that is latest (i.e. comes second). So for example, this

date x = latest(today, st_swithins_day);

print(x)

should also print todays date.

Part C. Define a function called next, which takes one date as its parameter, and modifies that date by moving it on to the next day, so this

next(today);

print(today);

next(today);

print(today);

would print

Wednesday November 23rd 2011

Thursday November 24th 2011

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!