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 ad61f56 commit 9d391ddCopy full SHA for 9d391dd
CPP/set & pair/pairCreation.cpp
@@ -0,0 +1,22 @@
1
+#include<bits/stdc++.h>
2
+using namespace std;
3
+int main(){
4
+
5
+//Pair is a way of creating a Composite datatypes
6
+// pair<int,int> p; //a pair of 2 ints
7
+// pair<int,string> p; //a pair of an int and a string
8
+// pair<vector<int>,string> p; //a pair of a (vector of int) and a string
9
10
+//accessing the elements using .first and .second
11
+pair<string,int> p={"hello", 6};
12
+cout<<p.first<<" "<<p.second; //prints: hello 6
13
14
+//Advantages: in case, you want to return multiple values from a function.
15
16
+//pair<vector<pair<int,vector<int>>>, string>
17
18
+pair<int,string> a={4, "xyz"};
19
+p.first = 13;
20
+cout<<p.first<<" "<<p.second;
21
22
+}
0 commit comments