C++ 标准模板库 (STL) 中的 Pair
在本教程中,我们将讨论一个程序来理解 C++ 标准模板库中的 pair。
Pair 是 utility 标头中定义的一个容器,它包含两个值。它用于组合两个值并关联它们,即使它们是不同类型的。
示例
#include <iostream>
#include <utility>
using namespace std;
int main(){
//initializing a pair
pair <int, char> PAIR1 ;
PAIR1.first = 100;
PAIR1.second = 'G' ;
cout << PAIR1.first << " " ;
cout << PAIR1.second << endl ;
return 0;
}输出
100 G
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP