#include <iostream>
#include <string>
class DateOfBirth
{
public:
DateOfBirth(int d, int m, int y) : day(d), month(m), year(y) {}
void displayDOB()
{
std::cout << day << "/" << month << "/" << year;
}
private:
int day;
int month;
int year;
};
class Person
{
public:
Person(std::string n, DateOfBirth d) : DOB(d), name(n) {} //1
Person(std::string n, int d, int m, int y) : DOB(d, m, y), name(n) {} //2
const std::string& getName() { return name; }
DateOfBirth DOB;
private:
std::string name;
};
int main()
{
Person person1("Person1", 1, 1, 1); //Calling (2)
Person person2("Person2", DateOfBirth(2, 2, 2)); //Calling (1) using temporary
Person person3("Person3", {3, 3, 3}); //Calling (1) using temporary
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3RyaW5nPgoKY2xhc3MgRGF0ZU9mQmlydGgKewogICAgcHVibGljOgogICAgICAgIERhdGVPZkJpcnRoKGludCBkLCBpbnQgbSwgaW50IHkpIDogZGF5KGQpLCBtb250aChtKSwgeWVhcih5KSB7fQoKICAgICAgICB2b2lkIGRpc3BsYXlET0IoKSAKICAgICAgICB7ICAgIAogICAgICAgICAgICBzdGQ6OmNvdXQgPDwgZGF5IDw8ICIvIiA8PCBtb250aCA8PCAiLyIgPDwgeWVhcjsKICAgICAgICB9CiAgICBwcml2YXRlOgogICAgICAgIGludCBkYXk7CiAgICAgICAgaW50IG1vbnRoOwogICAgICAgIGludCB5ZWFyOwp9OwoKY2xhc3MgUGVyc29uCnsKICAgIHB1YmxpYzoKICAgICAgICBQZXJzb24oc3RkOjpzdHJpbmcgbiwgRGF0ZU9mQmlydGggZCkgICAgICAgOiBET0IoZCksICAgICAgIG5hbWUobikge30gLy8xCiAgICAgICAgUGVyc29uKHN0ZDo6c3RyaW5nIG4sIGludCBkLCBpbnQgbSwgaW50IHkpIDogRE9CKGQsIG0sIHkpLCBuYW1lKG4pIHt9IC8vMgoKICAgICAgICBjb25zdCBzdGQ6OnN0cmluZyYgZ2V0TmFtZSgpIHsgcmV0dXJuIG5hbWU7IH0KICAgICA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