Hi,
I'm trying to create a list where the user inputs a first name and a last name to the list. After the user feels satisfied with the number of persons in the list the program will go back to the menu. And now comes the problem that I have, when I choose to "Write out the list" the list is completely empty regardless of the number of persons I put in. Maybe the only way to do this is to save all the names to a file?
Currently the vector<Person> in coutlist() and the vector<Person> in addname() don't know about each other because they are both defined within their respective functions and go out of scope when these functions return.
You need to declare a common vector<Person> in main() and push_back this vector with each person created (which becomes the addname() function) and then pass this vector<Person> to coutlist() when it comes to printing the Person objects.
Incidentally, line 61, you should pass by reference and line 31, instead of magic numbers use:
main thing is to pass the vector by reference to adddname() otherwise it just populates a copy of persons and when you go back to print out persons there'd be nothing in there of course