《04737 C++程序设计份历年真题1答案(2020年12月整理).doc》由会员分享,可在线阅读,更多相关《04737 C++程序设计份历年真题1答案(2020年12月整理).doc(14页珍藏版)》请在金锄头文库上搜索。
1、switch语句,找到第一个满足的case之后,如果没有break,会继续执行后面的case语句. double operator()(double x,double y) const;#include #include using namespace std;class Birthdaypublic: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()
2、coutyear-month-dayendl;class Personpublic: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;coutShow( );void main( )Person* p = new Person(张三,女,2000,10,13);p-Show();delete p;14C+程序设计 试卷第 页 共 14 页