// Project PersonMap, File main.cpp // Show how to use the STL map data structure. // Disable map warning number 4786 peculiar to // Microsoft implementation. #pragma warning(disable: 4786) #include #include #include #include "..\\person.h" using namespace std; int main() { // Declare map with keys of type string // and objects of type Person. map x; // Declare Person object for input. Person p; // Declare and open file object. ifstream fin("c:\\persons.txt"); // Load objects into map using name as key. while(fin >> p) x[p.get_name()] = p; // Get selected objects from map using key. p = x["Susan"]; cout << p.get_name() << " " << p.get_gender() << " " << p.get_age() << endl; p = x["Chloe"]; cout << x["Chloe"].get_name() << " " << p.get_gender() << " " << p.get_age() << endl; p = x["Scott"]; cout << p.get_name() << " " << p.get_gender() << " " << p.get_age() << endl; return EXIT_SUCCESS; }