A class definition for a date class that contains three


1. A class definition for a Date class that contains three integer data members: month, day, and year.

2. One constructor that assigns the date 1/1/2000 to any new object that does not receive any arguments.

3. One constructor that accepts month and day arguments and uses a default year of 2004.

4. One constructor that accepts month, day, and year arguments.

5. Each constructor should also output a message to the user stating which constructor is currently being used.

6. A method that displays the values in the Date object.

7. A Main() program in which you:

a. Instantiate three Date objects - create one for each type of constructor (no argument, 2-argument, 3-argument).

b. For the 2-argument and 3-argument constructor prompt the user for console input of the month, day or month, day, year.

c. Display output for each of the three constructor types.

8. Internal Documentation

Your output should look something like this:

Implementing overloaded constructors program
************************************
Using no-argument constructor, assigning date 1/1/2000
The date in this object is 1/1/2000
************************************
Enter a month eg: 10 for October: 10
Enter a day eg: 24: 24
Using 2-argument constructor, assigning year 2004
The date in this object is 10/24/2004
************************************
Enter a month eg: 10 for October: 8
Enter a day eg: 24: 25
Enter a year eg: 1950: 1951
Using 3-argument constructor, for mo/da/yr
The date in this object is 8/25/1951
************************************
Press any key to continue . . .

A constructor must have the same name as the class. A constructor is automatically called when an object is instantiated. A constructor is the most appropriate place to initialize data members.

Here is an example of declaring a constructor:

public class Date
{
public Date() //no argument constructor
{

...code to initialize variables

}
}

Solution Preview :

Prepared by a verified Expert
C/C++ Programming: A class definition for a date class that contains three
Reference No:- TGS01248463

Now Priced at $20 (50% Discount)

Recommended (91%)

Rated (4.3/5)