#include <iostream> using namespace std; class Date{ private: int year,month,day; public: Date(int year=1,int month=1,int day=1) { this->year=year; this->month=month; this->day=day; } Date(Date &d) { year=d.year; month=d.month; day=d.day; } void show() { cout<<year<<"/"<<month<<"/"<<day; } ~Date(){ } }; class Person{ private: int number; char sex; Date date; long int id; public: Person(){ } Person(int n,char s,Date d,long int i) { number=n; sex=s; date=d; id=i; } void show() { cout<<"编号"<<number<<"性别"<<sex<<" 出生日期"; date.show(); cout<<" 身份证号"<<id<<endl; } Person(Person &p) { number=p.number; sex=p.sex; date=p.date; id=p.id; } ~Person(){ } }; int main() { Date D(2004,9,16); Person P(1,'f',D,130582); Person P0; P0=P; P.show(); P0.show(); }
标签:选做,int,month,课后,year,Date,习题,day From: https://www.cnblogs.com/Lyh3012648079/p/17347818.html