#include #include #include using namespace std; class Person { public: Person(string n, int a) : name{n}, age{a} {} Person& operator++() { ++age; return *this; } Person operator++(int) { Person temp{*this}; ++age; return temp; } bool operator<(Person const& rhs) { return age < rhs.age; } friend ostream& operator<<(ostream & lhs, Person const& rhs) { lhs << "name: " << rhs.name << "\nage: " << rhs.age; return lhs; } private: string name; int age; }; int main() { Person p1{"Pontus", 30}; Person p2{"Janos", 25}; cout << p1 << endl; //operator<< (ostream, Person) ++p1; //operator++ () p1++; //operator++ (int) p1 < p2; //operator< (Person) }