inheritance and composition

YoungJoon Suh·2023년 8월 11일

In the case of inheritance, use the class name to invoke the base class's constructor.
In the case of composition, use the member object name to invoke its own constructor.

class personalInfoType
{
public:
void setPersonalInfo(string first, string last, int month, int day, int year, int ID);
void printPersonalInfo () const;
personalInfoType(string first = "", string last = "", int month = 1, int day = 1, int year = 1900, int ID = 0);
private:
personType name;
dateType bDay;
int personID;

personalInfoType::personalInfoType(string first, string last, int month, int day, int year, int ID)
: name(first, last), bDay(month, day, year)
{ }

void personalInfoType::setPersonalInfo(string first, string last, int month, int day, int year, int ID)
{
name.setName(first,last);
bDay.setDate(month,day,year);
personID = ID;
}

void personalInfoType::printPersonalInfo() const
{
name.print();
cout << "'s date of birth is ";
bDay.printDate();
cout << endl;
cout << "and personal ID is " << personID;
}

personalInfoType::personalInfoType(string first, string last, int month, int day, int year, int ID)

: name(first, last), bDay(month, day, year)
{
personID = ID;
}

profile
저는 서영준 입니다.

0개의 댓글