insert in pair code example
Example 1: pair c++
#include <utility>
#include <iostream>
int main () {
std::pair <int,int> foo;
std::pair <int,int> bar;
foo = std::make_pair (10,20);
bar = std::make_pair (10.5,'A');
std::cout << "foo: " << foo.first << ", " << foo.second << '\n';
std::cout << "bar: " << bar.first << ", " << bar.second << '\n';
return 0;
}
Example 2: insert a value in pair in c++
#include<bits/stdc++.h>
using namespace std;
int main(){
pair<string,int> p;
p.first = "Empty String";
p.second = 100;
cout<<p.first;
cout<<endl;
cout<<p.second;
return 0;
}