#include "Person.h" #include "PersonException.h" #include "YoungPerson.h" #include #include #include using std::cout; std::shared_ptr Person::GetPerson(std::string name, int age) { if (age < 18) return std::make_shared(name, age); return std::make_shared(name, age); } Person::Person(std::string name, int age) : name(name), age(age) { if (age < 0) { throw PersonException("negative age"); } cout << "Person ctor\n"; Count++; } Person::Person(const Person &) { cout << "Copy ctor\n"; Count++; } Person::~Person() { cout << "Dtor\n"; Count--; } void Person::setSalary(int sal) { if (sal < 0) { throw PersonException("negative salary"); } salary = sal; } int Person::GetCount() { return Count; } int Person::Count = 0;