您的位置:首页 > 大数据 > 人工智能

[STL] pair

2015-09-13 08:52 405 查看

[STL] pair总结

STL pair总结

属性

定义并赋值

属性

比较运算符

先比较first, first相等时比较second。

头文件

据说是需要
#include<utility>
,但是在本地好像下不需要。。。

定义并赋值

直接定义

[code]pair<string, int> f("hello", 7);
cout << f.first << ' ' << f.second;


[code]pair<string, int> *f = new pair<string, int>("hello", 7);
cout << f -> first << ' '<< f -> second


[code]pair<string, int> fct[100], *p = fct;
pair<string, int> *f = ++ p;


插入

[code]pair<string, int> f;
f = make_pair("hello", 7);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: