问答题 试题八(15 分,每空3 分) 阅读以下说明和C++程序,将应填入 (n) 处的字句写在答题纸的对应栏内。 [说明] 下面程序的功能是计算并输出某年某月的天数。 [C++程序] #include using namespace std; (1) Month{Jan, Feb, Mar, Apr,May,Jun, Jul, Aug, Sep,Oct,Nov,Dec}; class Date{ public: Date(int year, Month m_month){ (2) = year; if(m_month< Jan || m_month > Dec) month = Jan; else month = m_month; }; ~Date(){}; bool IsLeapYear(){ return ((year % 4 == 0 && year % 100 != 0) || year % 400 ==0); }; int CaculateDays(){ switch( (3) ){ case Feb:{ if( (4) ) return 29; else return 28; } case Jan: case Mar: case May: case Jul: case Aug: case Oct: case Dec: return 31; case Apr: case Jun: case Sep: case Nov: return 30; } }; private: int year; Month month; }; void main(){ Date day(2000,Feb); cout << day. (5) (); }
【正确答案】(1) enurn (2) this->year (3) month (4) IsLeapYear( ) (5) CaculateDays
【答案解析】