Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Date
- {
- public:
- date(); //The constructor with 0 arguments should set the date to January 1,1900.
- date(int, int, int); //The constructor with three int arguments should set the date based on the values of these arguments.
- date(string, int , int); //The constructor with a string and two int arguments should use the string to set the value of month (1 for “January”, and so on).
- void displayMonth(); // Member function displayMonth displays the month as a string
- private:
- int day;
- int month;
- int year;
- string month_names [12] = {"January","February","March","April","May","June","July", "August","September","October","November","December"};
- };
- //implementation
- Date::date()
- {
- day = 1;
- month = 1;
- year = 1900;
- }
- Date::date(int Day, int Month, int Year) date ( 1, 1, 1996)
- {
- day = Day; month = Month; year = Year;
- }
- Date::date(int day , string Month, int year )
- {
- for(int i = 0; i < 12; ++i)
- {
- if(month_names[i] == month)
- {
- Month = i;
- }
- }
- cout<<month_names[Month];
- }
- void displayMonth()
- {
- cout<<month_names[]
- }
- #include <iostream>
- using namespace std;
- int main()
- {
- int day, month, year;
- cout<<"Enter the number of day, month, year";
- cin>>day>>month>>year;
- if(day>31) break;
- if(month>12) break;
- if (year<1900||year>2010) break;
- Date date(day, month, year); //constructor
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement