Adding a new entry into a list of maps?

How do I add a new entry into this Phonebook program? This is what I have so far. Any tip or help would be great.

void enterNewEntry(std::map<std::string, std::list<PhoneEntry>*> & phoneInfo) {

    string  firstName;
    string  lastName;
    string  phoneNumStr;
    priority_t  priorityVal;

    enterFirstAndLastNames(firstName, lastName);
    enterPhoneNumStr(phoneNumStr);
    enterPriorityNum(priorityVal);
}

Answers


this code snippet doesn't provide info about PhoneEntry class, neither map key, but still:

auto someList = new std::list<PhoneEntry>(); //creating empty list
someList->insert(phoneEntryObject);          //fill list with data
phoneInfo[someName] = someList;              //insert pair - key(someName) with mapped data(someList) into map container

don't forget to manually free memory, even when you want to just erase element

Would suggest you to take a look at std::multimap STL container.


Need Your Help

Setting datetime axis limits offsets values

r datetime ggplot2 time-series

I have a plot made up of several segments (see below). To keep it simple, I give an example with one segment. It starts at 08:00 one day, and ends at 09:00 the same day. The timezone is UTC.

App does not start in Emulator

c# android xamarin xamarin.android

I am trying to create an app with Xamarin.Android. The app does not start in the android emulator.