pair in c++
C++
//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;
}
// 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;
}pair& operator= (const pair& pr);//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
- c++ code to print hello world
- Category
- C++
- Title
- set of vectors c++
- Category
- C++
- Title
- getting a random letter in c++
- Category
- C++
- Title
- trovare il valore massimo in un array c++ w3
- Category
- C++
- Title
- cout value c++
- Category
- C++
- Title
- c++ isalphanum
- Category
- C++
- Title
- sieve of eratosthenes c++
- Category
- C++
- Title
- c++ while true
- Category
- C++
- Title
- inheritance protected in c++
- Category
- C++
- Title
- console colors in C++
- Category
- C++
- Title
- dijkstra in c++
- Category
- C++
- Title
- pyqt connect
- Category
- C++
- Title
- Runtime Error: Runtime ErrorAbort signal from abort(3) (SIGABRT)
- Category
- C++
- Title
- variabvles in c++
- Category
- C++
- Title
- Temporary file using MSFT API in cpp
- Category
- C++
- Title
- exponenciacion binaria
- Category
- C++
- Title
- vector concat c++
- Category
- C++
- Title
- best fit algorithm
- Category
- C++
- Title
- how to use max_element in c++ with vector
- Category
- C++
- Title
- c++ convert int to cstring
- Category
- C++
- Title
- string to number in c++
- Category
- C++
- Title
- file objects in c++
- Category
- C++
- Title
- std::iomanip c++
- Category
- C++
- Title
- c++ code 2d block
- Category
- C++
- Title
- pair in c++
- Category
- C++
- Title
- dijkstra c++ geeksforgeeks using set
- Category
- C++
- Title
- syntax c++
- Category
- C++
- Title
- new in c++
- Category
- C++
- Title
- how to iterate trough a vector in c++
- Category
- C++
- Title
- iostream library in cpp
- Category
- C++
- Title
- find height of a tree
- Category
- C++
- Title
- check if intent has extras
- Category
- C++
- Title
- multiple words C++ in same
- Category
- C++
- Title
- stack c++
- Category
- C++
- Title
- how to delete an element in vector pair in cpp
- Category
- C++
- Title
- how to use a new node c++
- Category
- C++
- Title
- const in c++
- Category
- C++
- Title
- string substr c++
- Category
- C++
- Title
- c++ yes no question
- Category
- C++
- Title
- what are the different ways to traverse a binary tree
- Category
- C++
- Title
- C++ remove element from set
- Category
- C++
- Title
- c++ function to find length of array
- Category
- C++
- Title
- double to int c++
- Category
- C++
- Title
- c++ overload operator
- Category
- C++
- Title
- how to get last element of set in c++
- Category
- C++
- Title
- binary representation differ in bits
- Category
- C++
- Title
- find in vector in c++
- Category
- C++
- Title
- c++ char print align
- Category
- C++
- Title
- properties of a set c++
- Category
- C++
- Title
- converting char to int in c++
- Category
- C++
- Title
- Operator overloading in C++ Programming
- Category
- C++
- Title
- shuffle vector c++
- Category
- C++
- Title
- min heap declaration in c++ stl
- Category
- C++
- Title
- object slicing in c++
- Category
- C++
- Title
- qt make widget ignore mouse events
- Category
- C++
- Title
- compile c++ program
- Category
- C++
- Title
- case label in c++
- Category
- C++
- Title
- stringstream in c++ with delimiter
- Category
- C++
- Title
- c++ formatting
- Category
- C++
- Title
- counting valleys hackerrank solution in c++
- Category
- C++
- Title
- jump to case label c++
- Category
- C++
- Title
- declaring 2d vector in c++
- Category
- C++
- Title
- Find the minimum difference between pairs in a simple path of tree C++
- Category
- C++
- Title
- c++ program how to let the user choose different game modes
- Category
- C++
- Title
- c++ throw exception
- Category
- C++
- Title
- how to use wasd c++
- Category
- C++
- Title
- array<string, 7> c++
- Category
- C++
- Title
- convert char to string - c++
- Category
- C++
- Title
- class is replace by structure
- Category
- C++
- Title
- arduino falling edge
- Category
- C++
- Title
- system("pause") note working c++
- Category
- C++
- Title
- C++ If
- Category
- C++
- Title
- RLE Encoding/Compression c++
- Category
- C++
- Title
- how to execute c++ program in cmd
- Category
- C++
- Title
- convert decimal to binary in c++
- Category
- C++
- Title
- how to make a heap using stl in c++
- Category
- C++
- Title
- struct c++
- Category
- C++
- Title
- Merge k sorted linked lists and return it as one sorted list.
- Category
- C++
- Title
- insert elements in array in c++11
- Category
- C++
- Title
- c++ vector iterator
- Category
- C++
- Title
- how to find the size of a character array in c++
- Category
- C++
- Title
- memcmp in cpp
- Category
- C++
- Title
- do while loop c++
- Category
- C++
- Title
- cut by delimiter c++
- Category
- C++
- Title
- range of long long in c++
- Category
- C++
- Title
- c++ create object
- Category
- C++
- Title
- basic ex of maps in c++
- Category
- C++
- Title
- how to compare two strings lexicographically in c++
- Category
- C++
- Title
- create a 2d array c++
- Category
- C++
- Title
- file format not recognized treating as linker script c++
- Category
- C++
- Title
- minimum swaps to sort an array
- Category
- C++
- Title
- how to cout in c++
- Category
- C++
- Title
- declaring vector c++
- Category
- C++
- Title
- char* to int in cpp
- Category
- C++
- Title
- matrix multiplication c++ eigen
- Category
- C++
- Title
- vector initialization c++
- Category
- C++
- Title
- deque c++
- Category
- C++
- Title
- c++ remove item from list
- Category
- C++
- Title
- create a dictionary cpp
- Category
- C++
- Title
- array sort c++
- Category
- C++