Question: Write a program that reads Person information from a file, create a Person object and store the information read into this object. Once the information
Write a program that reads Person information from a file, create a Person object and store the information read into this object. Once the information is stored in Persons array, print the information and sort it based on person age using Selection sort and show the result.
main.cpp
Reads information from groups.txt file provided and store the data into Persons array.
Displays the information of Person using overloaded output stream operator
Sorts the Persons array based on the age, using Selection Sort.
Displays the information of Person using overloaded output stream operator after sorting.
Before:
Person Name: Emma Jones, Age: Income:
Person Name: Noah Jackson, Age: Income:
Person Name: Olivia Hines, Age: Income:
Person Name: Liam Williamson, Age: Income:
Person Name: Sophia Smith, Age: Income:
Person Name: Mason Jones, Age: Income:
Person Name: Ava Davis, Age: Income:
Person Name: Jacob Moore, Age: Income:
Person Name: Isabella Thomas, Age: Income:
Person Name: William White, Age: Income:
Person Name: Mia Jackson, Age: Income:
Person Name: Ethan Harris, Age: Income:
Person Name: Abigail James, Age: Income:
Person Name: Emily Alexander, Age: Income:
Person Name: Charlotte Martin, Age: Income:
Person Name: Michael Garcia, Age: Income:
Person Name: Benjamin Harper, Age: Income:
After:
Person Name: Emma Jones, Age: Income:
Person Name: Isabella Thomas, Age: Income:
Person Name: Mia Jackson, Age: Income:
Person Name: Benjamin Harper, Age: Income:
Person Name: Sophia Smith, Age: Income:
Person Name: Jacob Moore, Age: Income:
Person Name: William White, Age: Income:
Person Name: Emily Alexander, Age: Income:
Person Name: Olivia Hines, Age: Income:
Person Name: Ethan Harris, Age: Income:
Person Name: Mason Jones, Age: Income:
Person Name: Michael Garcia, Age: Income:
Person Name: Ava Davis, Age: Income:
Person Name: Liam Williamson, Age: Income:
Person Name: Noah Jackson, Age: Income:
Person Name: Abigail James, Age: Income:
Person Name: Charlotte Martin, Age: Income:
Class Description
Person.h
Constructor: Assigns age, first name, last name, salary in the same order.
operator function: You need to overload operator to return true if age of lhs person is less than age of rhs person else false.
operator function: Prints the person as specified in sample output below.
Person pAa
cout
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
