#include using namespace std; /* 知识点内容:STL map详解 Map是STL的一个关联容器,它提供一对一(其中第一个可以称为关键字,每个关键字只能在map中出现一次,第二个可能称为该关键字的值)的数据处理能力, 由于这个特性,它完成有可能在我们处理一对一数据的时候,在编程上提供快速通道。 文档内容参考: https://www.cnblogs.com/aiguona/p/7231451.html * */ int main() { map a;//定义map函数 a.insert(map::value_type('c', 1));//插入元素 a.insert(map::value_type('d', 2)); map::iterator b = a.find('c');//查找元素 map::const_iterator it; for (it = a.begin(); it != a.end(); ++it) cout << it->first << "=" << it->second << endl; cout << endl; a.clear();//删除所有元素 return 0; }