c++标准库pair小例

来源:互联网 发布:windows lua环境变量 编辑:程序博客网 时间:2024/06/05 07:18
#include <iostream>#include <utility>#include <string>using namespace std;pair<int,string> func(int a, string s) {return make_pair(a,s);}int main() {pair<int, string> t = func(1314, "I love you");cout << get<0>(t) << endl;//获得第一个数cout << get<1>(t) << endl;//获得第二个数//修改他们的第一个数的值get<0>(t) = 1314520;cout << get<0>(t) << endl;//获得第一个数cout << get<1>(t) << endl;//获得第二个数system("pause");return 0;}