make_pair (STL Samples)
发布日期:2022-02-10 13:35:54
浏览次数:40
分类:技术文章
本文共 945 字,大约阅读时间需要 3 分钟。
Illustrates how to use the Standard Template Library (STL) function in Visual C++.
templateinline pair make_pair( const first& _X, const second& _Y )
The make_pair STL function creates a pair structure that contains two data elements of any type.
// 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 #include using namespace std;/* STL pair data type containing int and float*/typedef struct pair 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;}
18 3.14
10 1一句话解释:看函数声明我们知道这个make_pair其实是一个类模板,并且返回的是pair类型,make_pair会隐式的类型转换,是pair的智能版本.
参考:
转载地址:https://blog.csdn.net/zoopang/article/details/51152834 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!
发表评论
最新留言
不错!
[***.144.177.141]2024年03月22日 01时37分19秒
关于作者
喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
常用激活函数总结
2019-04-26
支持向量机(SVM)
2019-04-26
常用来划分测试集和训练集的划分方法
2019-04-26
Python 中__new__()和__init__()的区别
2019-04-26
平面点坐标旋转公式
2019-04-26
二叉树的问题汇总
2019-04-26
排序算法的时间复杂度汇总
2019-04-26
最小的k个数或者最大的k个数
2019-04-26
xgboost
2019-04-26
python的取余操作
2019-04-26
八皇后问题的解题思路
2019-04-26
动态规划问题
2019-04-26
python中全局变量与局部变量
2019-04-26
内存中堆和栈的区别,以及C语言中的内存模型
2019-04-26
两个单链表的求和,将矩阵元素全部对换
2019-04-26
KMP字符串匹配算法
2019-04-26
图算法:一种比线性表和树更复杂的数据结构
2019-04-26
网络安全工程师的初学路径
2019-04-26
离群点检测和新奇检测之离群点检测
2019-04-26
离群点检测和新奇检测之新奇检测
2019-04-26