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