pair c++
C++
// make_pair example
#include <utility> // std::pair
#include <iostream> // std::cout
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'); // ok: implicit conversion from pair<double,char>
std::cout << "foo: " << foo.first << ", " << foo.second << '\n';
std::cout << "bar: " << bar.first << ", " << bar.second << '\n';
return 0;
}//CPP program to illustrate auto-initializing of pair STL
#include <iostream>
#include <utility>
using namespace std;
int main()
{
pair <int, double> PAIR1 ;
pair <string, char> PAIR2 ;
cout << PAIR1.first ; //it is initialised to 0
cout << PAIR1.second ; //it is initialised to 0
cout << " ";
cout << PAIR2.first ; //it prints nothing i.e NULL
cout << PAIR2.second ; //it prints nothing i.e NULL
return 0;
}
//CPP code to illustrate operators in pair
#include <iostream>
#include<utility>
using namespace std;
int main()
{
pair<int, int>pair1 = make_pair(1, 12);
pair<int, int>pair2 = make_pair(9, 12);
cout << (pair1 == pair2) << endl;
cout << (pair1 != pair2) << endl;
cout << (pair1 >= pair2) << endl;
cout << (pair1 <= pair2) << endl;
cout << (pair1 > pair2) << endl;
cout << (pair1 < pair2) << endl;
return 0;
}
Also in C++:
- Title
- inheritance protected in c++
- Category
- C++
- Title
- max in c++
- Category
- C++
- Title
- how to create object in c++
- Category
- C++
- Title
- how to initialize a vector in c++
- Category
- C++
- Title
- c++ program to input and print text using Dynamic Memory Allocation.loop
- Category
- C++
- Title
- c++ round to int
- Category
- C++
- Title
- print type cpp
- Category
- C++
- Title
- date to string c++
- Category
- C++
- Title
- how to get the prime number in c++ where time complexity is 0(log n)
- Category
- C++
- Title
- cpp create lambda with recursion
- Category
- C++
- Title
- traverse map c++
- Category
- C++
- Title
- call by reference c++ example
- Category
- C++
- Title
- pairs in c++
- Category
- C++
- Title
- log base e synthax c++
- Category
- C++
- Title
- c++ how to return an empty vector
- Category
- C++
- Title
- how to calculate inverse trigonometric values in c++
- Category
- C++
- Title
- how to sort vector in c++
- Category
- C++
- Title
- declaring 2d vector in c++
- Category
- C++
- Title
- c++ code to print hello world
- Category
- C++
- Title
- how to concatinate two strings in c++
- Category
- C++
- Title
- translate
- Category
- C++
- Title
- cout console
- Category
- C++
- Title
- new c++
- Category
- C++
- Title
- run program until ctrl-d c++
- Category
- C++
- Title
- sieve of eratosthenes c++
- Category
- C++
- Title
- find in vector in c++
- Category
- C++
- Title
- how to get a letter from the user c++ string
- Category
- C++
- Title
- registering a new QML type
- Category
- C++
- Title
- add a timer c++
- Category
- C++
- Title
- c++ movment
- Category
- C++
- Title
- static variable in c++
- Category
- C++
- Title
- initialize 3d vector c++
- Category
- C++
- Title
- pause the console c++
- Category
- C++
- Title
- how to format decimal palces in c++
- Category
- C++
- Title
- range based for loop c++
- Category
- C++
- Title
- how to modulo 10^9+7
- Category
- C++
- Title
- how to find the index of an element in a vector c++
- Category
- C++
- Title
- create new file c++
- Category
- C++
- Title
- how to delete a node c++
- Category
- C++
- Title
- cin.fail()
- Category
- C++
- Title
- maximum possible number atmost k swaps
- Category
- C++
- Title
- pyqt connect
- Category
- C++
- Title
- c++ code 2d block
- Category
- C++
- Title
- iterative inorder traversal
- Category
- C++
- Title
- sum of integer in array c++
- Category
- C++
- Title
- c++ map find
- Category
- C++
- Title
- euler phi gfg
- Category
- C++
- Title
- how to make string get spaces c++
- Category
- C++
- Title
- hohw toparse a string in c++
- Category
- C++
- Title
- pop_back
- Category
- C++
- Title
- c++ looping through a vector
- Category
- C++
- Title
- how to convert n space separated integers in c++
- Category
- C++
- Title
- how to turn int into string c++
- Category
- C++
- Title
- input a string in c++
- Category
- C++
- Title
- list conda environments
- Category
- C++
- Title
- c++ remove space from string
- Category
- C++
- Title
- can you use a return to print a string when referencing an integer c++
- Category
- C++
- Title
- convert entire string to lowercase c++
- Category
- C++
- Title
- heap sort
- Category
- C++
- Title
- how to know the correct class of objects cpp
- Category
- C++
- Title
- how to check datatype of a variable in c++
- Category
- C++
- Title
- peak in c++
- Category
- C++
- Title
- sum of two numbers c++
- Category
- C++
- Title
- body parser
- Category
- C++
- Title
- user input c++
- Category
- C++
- Title
- substitution failure is not an error
- Category
- C++
- Title
- find all the palindrome substring in a given string
- Category
- C++
- Title
- merge sort in c++
- Category
- C++
- Title
- how to cout in c++
- Category
- C++
- Title
- sub string of vector c++
- Category
- C++
- Title
- iostream library in cpp
- Category
- C++
- Title
- dfs in c++
- Category
- C++
- Title
- how to print eachh chars in string data type in c++
- Category
- C++
- Title
- can you use rand to read in from an external file inc++
- Category
- C++
- Title
- binary tree search
- Category
- C++
- Title
- how to use max_element in c++ with vector
- Category
- C++
- Title
- c++ method name
- Category
- C++
- Title
- c++ yes no question
- Category
- C++
- Title
- find upper bound c++ vector
- Category
- C++
- Title
- c++ wait for user input
- Category
- C++
- Title
- calling by reference c++
- Category
- C++
- Title
- 1d fixed length arrays c++
- Category
- C++
- Title
- c++ typedef
- Category
- C++
- Title
- c++ do while loop
- Category
- C++
- Title
- get index of value c++
- Category
- C++
- Title
- c++ map insert
- Category
- C++
- Title
- string to vector c++
- Category
- C++
- Title
- how are graphics in games made
- Category
- C++
- Title
- c++ crash windows
- Category
- C++
- Title
- initialise 2d vector in c++
- Category
- C++
- Title
- stoi c++
- Category
- C++
- Title
- c++ read matttrix from text file
- Category
- C++
- Title
- how to import getline in c++
- Category
- C++
- Title
- find in set of pairs using first value cpp
- Category
- C++
- Title
- static_cast c++
- Category
- C++
- Title
- pair in c++
- Category
- C++
- Title
- c++ files
- Category
- C++
- Title
- how to check a number in string
- Category
- C++
- Title
- how to append two vectors in c++
- Category
- C++
- Title
- unordered_map c++ insert
- Category
- C++