Files
cppcourse/397/Ex62/Main.cpp
T
2026-10-05 11:27:21 +02:00

54 lines
1.2 KiB
C++

#include "Person.h"
#include <algorithm>
#include <cctype>
#include <iostream>
#include <list>
//#include <fstream>
// include headers that implement an archive in simple text format
//#include <boost/archive/text_oarchive.hpp>
//#include <boost/archive/text_iarchive.hpp>
// include header that allows serialization of STL list
//#include <boost/serialization/list.hpp>
// STL collection of Person*
std::list<Person *> people;
void add() {
// creates a person, collects the information, adds person to list
Person *newP = new Person;
newP->askForInfo();
people.push_back(newP);
}
void showPerson(Person *p) {
// displays a person
p->display();
}
void display() {
// displays all the people
std::for_each(people.begin(), people.end(), &showPerson);
}
int main() {
char choice = 0;
while (choice != 'X') {
switch (choice) {
case 'A':
add();
break;
case 'D':
display();
break;
}
std::cout << "Enter choice: [A]dd, [D]isplay, e[X]it: ";
std::cin >> choice;
choice = std::toupper(choice);
}
return 0;
}