初始化:
map<string,int> m_map;
m_map.insert(map<string,int>::value_type("hello",5));//方法一
m_map.insert(make_pair("hello",5));//方法二
访问
m_map["hello"];
m_map.at("hello");
遍历
for (auto iter: m_map)
{
iter.first;//key
iter.second;//value
}
map与multimap差别仅仅在于multimap允许一个键对应多个值
网友评论