04737 C++程序设计201704月份历年真题1-答案.docVIP

  • 39
  • 0
  • 约1.07千字
  • 约 14页
  • 2018-11-08 发布于浙江
  • 举报

04737 C++程序设计201704月份历年真题1-答案.doc

04737 C++程序设计201704月份历年真题1-答案.doc

C++程序设计 试卷第 PAGE 14 页 共 NUMPAGES 14 页 switch语句,找到第一个满足的case之后,如果没有break,会继续执行后面的case语句. double operator()(double x,double y) const; switch语句,找到第一个满足的case之后,如果没有break,会继续执行后面的case语句. double operator()(double x,double y) const; #include iostream #include string using namespace std; class Birthday{ public: Birthday(int y,int m,int d); Show(); private: int year; int month; int day; }; Birthday::Birthday(int y,int m,int d){ year = y; month = m; day = d; } Birthday::Show(){ coutyear-month-dayendl; } class Person{ public: Person(string n,string s,int y,int m,int d); ~Person( ); Show(); private: string name; string sex; Birthday* birthday; }; Person::Person(string n,string s,int y,int m,int d){ name = n; sex = s; birthday = new Birthday(y,m,d); } Person::~Person( ) { if ( birthday != NULL ) { delete birthday; birthday = NULL; } } Person::Show(){ cout姓名:nameendl; cout性别:sexendl; cout生日:; birthday-Show( ); } void main( ){ Person* p = new Person(张三,女,2000,10,13); p-Show(); delete p; }

文档评论(0)

1亿VIP精品文档

相关文档