#include "iostream" using namespace std; class Date { public: Date(); Date(int year, int month, int day); Date(const Date &date); ~Date(); int getYear() const; int getMonth() const; int getDay() const; private: int year = 1970; int month = 1; int day = 1; }; Date::Date(int year, int month, int day) : year(year), month(month), day(day) { std::cout << "Date::Date(int year, int month, int day)" << std::endl; } Date::Date() : year(1970), month(1), day(1) {} Date::Date(const Date &date) { cout << "Date::Date(const Date &p)" << endl; Date::year = date.year; Date::month = date.month; Date::day = date.day; } Date::~Date() { std::cout << "Date::~Date()" << std::endl; } int Date::getYear() const { return year; } int Date::getMonth() const { return month; } int Date::getDay() const { return day; } //------------------------------------------------- class Person { public: Person(); Person(char *name, const Date &birthday); ~Person(); void showPerson(); private: string name; Date birthday; }; Person::Person() { cout << "Person::Default constructor Function is called." << endl; } Person::Person(char *name, const Date &birthday) : name(name), birthday(birthday) { cout << "Person::Constructor Function is called." << endl; } Person::~Person() { std::cout << "Person::~Person()" << std::endl; } void Person::showPerson() { cout << "Person::showPerson()" << endl; cout << "Name:" << name << " "; cout << "Birthday:" << birthday.getYear() << '-' << birthday.getMonth() << '-' << birthday.getDay(); cout << endl; } int main() { char name[20]; int y, m, d; int Cas = 0; cout << "Please input name & birthday:\n"; while (cin >> name >> y >> m >> d) { Cas++; cout << "CASE #" << Cas << ":" << endl; Date d1(y, m, d); Person person(name, d1); person.showPerson(); } }