make_pair (STL Samples)
来源:互联网 发布:社工数据库手机号 编辑:程序博客网 时间:2024/05/22 06:48
Illustrates how to use the make_pair Standard Template Library (STL) function in Visual C++.
template<class first, class second> inline pair<first, second> make_pair( const first& _X, const second& _Y )Remarks
The make_pair STL function creates a pair structure that contains two data elements of any type.
Example
<span style="font-size:14px;">// mkpair.cpp// compile with: /EHsc// Illustrates how to use the make_pair function.//// Functions: make_pair - creates an object pair containing two data// elements of any type.#include <utility>#include <iostream>using namespace std;/* STL pair data type containing int and float*/typedef struct pair<int,float> PAIR_IF;int main(void){ PAIR_IF pair1=make_pair(18,3.14f); cout << pair1.first << " " << pair1.second << endl; pair1.first=10; pair1.second=1.0f; cout << pair1.first << " " << pair1.second << endl;}</span>Output
18 3.14
10 1一句话解释:看函数声明我们知道这个make_pair其实是一个类模板,并且返回的是pair类型,make_pair会隐式的类型转换,是pair的智能版本.
参考:点击打开链接
1 0
- make_pair (STL Samples)
- 一个STL的函数make_pair()
- STL pair make_pair简单使用
- make_pair()
- make_pair
- make_pair
- make_pair
- make_pair
- make_pair
- make_pair
- make_pair
- 【STL】pair与make_pair的简单例子
- stl map用法和make_pair函数
- stl map用法和make_pair函数
- stl map用法和make_pair函数
- STL map详细用法和make_pair函数
- stl map用法和 make_pair函数
- STL map详细用法和make_pair函数
- 国外人气最旺的软件测试网站
- POJ 2255/hrbust 2022 Tree Recovery【dfs、二叉树的层次遍历】
- 2015最流行的Android组件、工具、框架大全
- Volley的网络请求实例
- Android Studio中SDK版本为23时不能引用http包
- make_pair (STL Samples)
- Intent 用法总结
- 10的阶乘
- Jackson学习笔记(二)
- 微信开发之ngrok代理外网访问工具的使用
- vs2010操作 office2010自我笔记
- VB程序语言3
- Android API Guides---Providing Resources
- OA项目实战学习(6)——权限模型设计