Adding elements to map

How can i add elements to map while program is running. I tied [] and insert but both give access violation.

1
2
3
4
5
6

std::map<std::string, std::string> links;

void AlbumsController::addAlbumLink(std::string link, std::string name) {
	links.insert(std::pair<std::string, std::string>(link, name));
}
Can you post the error that you get and possibly the full code?

This didn't work?
1
2
3
void AlbumsController::addAlbumLink(std::string link, std::string name) {
	links[link] =  name;
}
Last edited on
Fixed it... I forgot to initialize the albumscontroller. So i was callin the function on a null object... Silly me.. :D
Topic archived. No new replies allowed.