我是靠谱客的博主 飞快曲奇,最近开发中收集的这篇文章主要介绍STL之map定义,使用与遍历,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

#include<iostream>
#include<map>
using namespace std;
int main(){
	map<string,int> m;
	m["a"]=3;
	m["b"]=56;
	map<string,int>::iterator it;	//iterator即迭代器,it指代map中元素

	for(it=m.begin();it!=m.end();it++){
		cout << it->first << " " << it->second << " " << endl;	//此中it->first指代键,it->second指代值
	}

	it=m.begin();
	string s=it->first;
	int i=it->second;
	cout << s << " " << i << endl;
	i=m["b"];
	cout << i;

	return 0;
}

最后

以上就是飞快曲奇为你收集整理的STL之map定义,使用与遍历的全部内容,希望文章能够帮你解决STL之map定义,使用与遍历所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(75)

评论列表共有 0 条评论

立即
投稿
返回
顶部