C++ Programming Challenge: Working with Text Files and C++ Vector Of Objects

Share it with your friends Like

Thanks! Share it with your friends!


First read in, from the attached file called Program.txt, a series of names and ages. You should not assume you know how many rows are in the file.  You will save the file to the c:\temp location on your computer.
In the program, write a function called GetData that reads in the data into an array of objects that contain firstname, lastname, and age.
Then, define a class called person. You will have person.h and person.cpp files that will contain 3 private variables to hold the three values strFirstName, strLastName, and intAge. It should have public accessor and set functions, getFirstName, getLastName, getAge, setFirstName, setLastName, and setAge.
The main app should have a function called CalculateAvgAge that gets an array of objects (NOTE: we will be using C++ vector of objects) passed to it, and the number of objects in the array, and calculates the Avg age and returns it as a double in main.cpp.
So main.app should contain at least two functions, CalculateAvgAge and GetData.



Write a comment