The class Date has the following data members:
Month
Day
Year
and member functions:
A default constructor that initialises all data members to zero.
A constructor to create and initialise a Date object with the values passed as parameters
Assigndate to assign values to the data members from the keyboard in the format:
Day: 9
Month: 10
Year: 2002
Displayshort to display a date in short form e.g. “09/10/2002”
DisplayVerbose to display a date in form “October 9, 2002”
NextDay to change the date to next day e.g. “October 10, 2002”
(a) Write the class interface for the class Date.
(b) Write the full function implementation for the member functions of the class Date.
(c) Write a main program that declares two objects D1 and D2 of type Date. D1 must be initialised to the value “23 October 2002” and D2 must get its value from the keyboard. The program must then find the earlier of D1 and D2 and display the same in both formats. The program must also set the date D2 to next day and display the same in both formats.
ive started by doin the 3rd part c directly but dunno how to continue and if wat ive done is correct..this is wat ive manage to do uptil nw:
Expand|Select|Wrap|Line Numbers
- #include<iostream.h>
- #include<conio.h>
- class Date{
- char month[10];
- int month;
- int day;
- int year;
- public:
- Date();
- Date(char, int, int);
- void Assigndate();
- void Displayshort();
- void DisplayVerbose();
- void NextDay();
- }
- Date::Date()
- { month=0;
- day=0;
- year=0;
- }
- void Assigndate()
- { cin>>day;
- cout<<"Day: "<<day<<endl;
- cin>>month;
- cout<<"Month: "<<month<<endl;
- cin>>year;
- cout<<"Year: "<<year<<endl;
- }
- void Displayshort()
- { cout<<day<<"/"<<month<<"/"<<year<<endl;
- }
- void NextDay()
- { D1.date(char, int, int)
- d++;
- cout<<D1;
- }
- void main(){
- Date D1,D2;
- cout<<"Enter the date"<<endl;
- cin>>date;
ive not completed it..hw do i display the date in different formats..plz correct it n how do i continue