11.15
mapped_type : vector< int >
key_type : int
value_type : std::pair< int, vector<int> >
11.16
std::map<int, std::string> map;
map[10010] = "132";
std::map<int, std::string>::iterator it = map.begin();
it->second = "131";
11.17
copy(v.begin(), v.end(), inserter(c, c.end())); // 合法
copy(v.begin(), v.end(), back_inserter(c)); // 不合法,multiset没有push_back。
copy(c.begin(), c.end(), inserter(v, v.end())); // 合法
copy(c.begin(), c.end(), back_inserter(v)); // 合法
11.18
std::map<std::string, size_t>::const_iterator;
11.19
using compareType = bool (*)(const Sales_data &lhs, const Sales_data &rhs);
std::multiset<Sales_data, compareType> bookstore(compareIsbn);
std::multiset<Sales_data, compareType>::iterator c_it = bookstore.begin();
本文详细介绍了 C++ STL 中的多种容器类型及其用法,包括 map 的插入与迭代操作,以及 multiset 和 vector 的元素复制方法。通过具体实例展示了不同容器的特点与适用场景。
2345

被折叠的 条评论
为什么被折叠?



