Here's a class definition. You'll have to implement its functions, create its instances, and find the eldest person.
class Person
{
public:
Person(const std::string& name, int year, int month, int day);
friend bool operator<(const Person& lhs, const Person& rhs);
private:
std::string name_;
int year_;
int month_;
int day_;
};
For a discussion of comparison operators like
operator<
, see the discussion halfway down
this page[
^]. Bookmark that site, which is my go-to reference for C++.
A good argument can be made that your design should first define a
Date
class for the
year_
,
month_
, and
day_
members, so that
Person
would only have
name_
and
date_
data members.
operator<
would then be a member of
Date
; it makes more sense to compare two dates than it does two people, and the
Date
class could then also be used by other classes that required a date.