#include #include using namespace std; /** * Definition of a Person * identified by its name and age */ class Person { // ============================================== // data members // ============================================== protected: // name of the person (default value is empty string) string name; // age of the person (default value is 0) int age; // ============================================== // methods // ============================================== public: /** * default constructor */ Person() { name = ""; age = 0; } /** * constructor with 2 arguments * @param n name of the person * @param a age of the person */ Person(string n, int a) { name = n; age = a; } /** * getter for name * @return name of the person */ string get_name() { return name; } /** * getter for age * @return age of the person */ int get_age() { return age; } /** * setter for name * @param n name of the person */ void set_name(string n) { name = n; } /** * setter for age * @param a age of the person */ void set_age(int a) { age = a; } /** * print class contents * @param output stream reference * @return output stream reference */ ostream& print(ostream& out) { out << name << ", " << age; return out; } friend ostream& operator<<(ostream& out, Person& p) { return p.print(out); } };