Hi all,
I need to pass the address of a map (from the std lib) to a function so it can have items added to it. But unfortunatly my understanding of pointers is rather limited. This is sort of what I need:
Code:
#include <iostream>
#include <string>
#include <map>
using namespace std;
int GetNames(map <string, string> &Names)
{
Names["John"] = "John Palmer";
return 0;
}
int main()
{
map<string, string>PeopleNames;
GetNames(&PeopleNames);
cout << PeopleNames["John"] << endl;
return 0;
}
Can anyone tell me how I can do this? It would be most appreciated