//
// main.cpp
// TestCPP
//
// Created by dragon on 2017/4/9.
// Copyright © 2017年 tars. All rights reserved.
//
int main(int argc, const char * argv[]) {
map<int, string> mapInfoB;
mapInfoB.clear();
mapInfoB.insert(make_pair(2, "Ba"));
map<int, string> mapInfo;
mapInfo.clear();
mapInfo.insert(make_pair(0, "a"));
mapInfo.insert(make_pair(2, "a"));
mapInfo[0] = mapInfoB[2]; // 0 和 2 都是key而不是数组中的下标,千万注意,十分危险危险危险:map是复杂数据类型使用千万注意
for (map<int,string>::iterator it = mapInfo.begin(); it != mapInfo.end(); it++)
{
cout<<it->second<<endl; //Ba a
}
std::cout << "Hello, World!n";
return 0;
}
最后
以上就是甜美机器猫最近收集整理的关于c++stl map数组下标的使用的全部内容,更多相关c++stl内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复