Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Date.cpp is the Date class function implemetation file.
- #include "Date.h"
- class Date // Default Class
- {
- private:
- int month;
- int day;
- int year;
- int DaysPerMonth[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
- public:
- Date(int m, int d, int y)
- {
- if (m < 1 || m > 12)
- month = 1;
- else
- month = m;
- if (d < 1 || d > DaysPerMonth[month - 1])
- day = 1;
- else
- day = d;
- if (y < 0)
- year = 2001;
- else
- year = y;
- }
- Date(){
- }
- void printDate1() // Print the Date in 1st style
- {
- cout << this->month << "/" << this->day << "/" << this->year << "\n"; // Display the date in m/d/y
- }
- void printDate2() // Print the Date in 2nd style
- {
- cout << Months[month - 1] << " " << day << ", " << year << endl; // Display the Date in m d, y
- }
- void printDate3() // Print the Date in 3rd style
- {
- cout << day << " " << Months[month - 1] << " " << year << endl; // Display the Date in d m y
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment