Home > Back-end >  For help
For help

Time:03-23

Define a class Date Date, the main () function to finish the test,

The Date class structure elucidation:
The Date class data members include:
Private data members: (1) year year (int), month to month (int), day day (int),
The Date class member functions include:
1) define the parameter constructor Date (int, int, int) and copy constructor Date (Date & amp;) , including the Constructor parameters default value is 1, the output information "Constructor run", the copy Constructor output information "CopyConstructor run"
(2) define the Destructor, the Destructor output information "Destructor run"
(3) members of the public function: void setYear (int) and int getYear () returns and set the year
(4) members of the public function: void setMonth (int) and int getMonth () returns and set the month
(5) members of the public function: void setDay (int) and int getday () returns and set the day
Those members of the public function: the void tomorrow () and void yesterday () implementation date plus/minus one day operation
7 members of the public function: void printMonthCalendar () to print the month calendar, format is as follows (each column width to three, right-aligned) (in March 2016, for example)
SunMonTueWedThuFriSat
1, 2, 3, 4, 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20, 21, 22, 23 24 25 26
27 28, 29 and 30, 31
End members of the public function: void chineseFormat () and void americaformat () respectively show Chinese date (example: on April 21, 2014) and American date (example: Api 21, 2014), the American format 1 ~ 12 month respectively with Jan, Feb, Mar, Api, May, Jun, Jul, Aug, Sep and Oct, Nov, Dec said
Pet-name ruby private member function: int isLeapYear () to determine whether the current year is a leap year, leap year to return to 1, otherwise it returns 0;
Attending members of the public function: int weekDay () returns the day of the week, respectively 0 to 6 Sun, Mon, Tue, Wed and Thu Fri, Sat,
Note: the above in the execution of a member function, if the date of the input parameter value in excess of the world, is in accordance with the effective date value towards the closest to the input parameters, such as:
Assume that the input month> If 12, 12, according to the input of month<1, according to the 1 treatment;
Assume that the current month to 12 month, if the input day> 31, according to 31, if the input day<1, according to the 1 treatment;
Tip: cout. Width (int) set the width of the output item

The referee sample testing program:
# include
using namespace std;
31,28,31,30,31,30,31,31,30,31,30,31 int const monthDay [12]={};
Const char * weekName [7]={" Sun ", "Mon, Tue, Wed," Thu ", "Fri", "Sat"};
Char * const monthName [12]={" Jan ", "Feb", "Mar", "Api", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov," "Dec"};

Please fill in the answer here */*/

Int main () {
Int year, month, day.
The Date d1;
The Date (d1, d2);
Cin> Year> Month> Day;
D1. SetYear (year);
D1. SetMonth (month);
D1. SetDay (day);
D1. Yesterday ();
D1. ChineseFormat ();
Cin> Year> Month> Day;
D2. SetYear (year);
D2. SetMonth (month);
D2. SetDay (day);
D2. Tomorrow ();
D2. Americaformat ();
D2. PrintMonthCalendar ();
return 0;
}
  • Related