您的位置:首页 > 移动开发

value_type, key_type, mapped_type, reference,const_reference

2014-09-25 21:02 176 查看
注意:map的value_type是一个(key,value)对,映射值的被认为是mapped_type。因此,一个map是一个pair<const Key,mapped_type>元素的序列。从const Key可以看出,map中键key是不可修改的。

int main() {
map<string, char> testMap;
testMap["A"] = 1;
map<string, char>::mapped_type mapVal = testMap["A"];

vector<int> testVector;
testVector.push_back(1);
vector<int>::value_type vectorVal = testVector[0];

printf("%d\n", mapVal);
printf("%d\n", vectorVal);
}


输出1, 1
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: