What is the correct operator< for the following class?
struct Person {
int height;
int width;
friend bool operator<(const Person&, const Person&);
};
Thanks!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
That’s entirely up to you and how you would want people to naturally sort. If you want short people first, but skinny to come before tall if they are the same height:
If you want some measure of a person’s surface area to determine ordering: