We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f843a6a commit 0bca5deCopy full SHA for 0bca5de
data-structures/Inbuilt_Pair.cpp
@@ -0,0 +1,28 @@
1
+/*
2
+Pair is a container class in CPP defined in <utility> header file. It consists of two elements.
3
+
4
+You can access the first element as 'first' and second element as 'second'. They both can be of any data type. (This class is made using templates)
5
6
+We can use the pair class where we need to store two properties like when finding diameter of a binary tree.
7
8
+This is the inbuilt version, we can create our own version too.
9
10
+*/
11
+#include<bits/stdc++.h>
12
+using namespace std;
13
14
+int main() {
15
16
+ pair <int, char> p ;
17
18
+ p.first = 100;
19
+ p.second = 'G' ;
20
21
+ cout << p.first << " " ;
22
+ cout << p.second << endl ;
23
24
+ return 0;
25
26
+}
27
28
0 commit comments