vector map 多层嵌套使用

#include <vector>
#include <map>

using namespace std;
typedef vector<int>			vectTemp;
typedef map<int,vectTemp>	mapTemp;
typedef map<int,mapTemp>	MapM;


void main()
{	
	vectTemp vectInt;
	mapTemp  mapVect;
	MapM	 mapMap;
	vectInt.push_back(1);
	mapVect[1] = vectInt;
	mapMap[1] = mapVect;
	printf("%d\n",vectInt[0]);
	printf("%d\n",mapVect[1][0]);
	printf("%d\n", mapMap[1][1][0]);
	mapMap[2][2].push_back(10);
	printf("%d\n", mapMap[2][2][0]);
	system("pause");
}




注意的是,vector访问未赋值的下标会越界,map访问未赋值的下标会创建一个新的并设置为0

posted @ 2013-08-28 10:47  byfei  阅读(2453)  评论(0编辑  收藏  举报