Search
 
SCRIPT & CODE EXAMPLE
 

CPP

std::pair c++ access element

#include <iostream>
#include <utility>

int main()
{
    std::pair<int,int> p = std::make_pair(1,2); //Creating the pair
    std::cout << p.first << " " << p.second << std::endl; //Accessing the elements




    //We can also create a pair and assign the elements later
    std::pair<int,int> p1;
    p1.first = 3;
    p1.second = 4;
    std::cout << p1.first << " " << p1.second << std::endl;

    //We can also create a pair using a constructor
    std::pair<int,int> p2 = std::pair<int,int>(5, 6);
    std::cout << p2.first << " " << p2.second << std::endl;

    return 0;
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: qstring mid 
Cpp :: remove last letter in string c++ 
Cpp :: cpp get data type 
Cpp :: c++ get files in directory 
Cpp :: number of cores c++ 
Cpp :: shuffle vector c++ 
Cpp :: how to print the address of an object in c++ 
Cpp :: c++ find minimum value in vector 
Cpp :: c++ copy file to another directory 
Cpp :: how to convert qt string to string 
Cpp :: programs for printing pyramid patterns in c++ 
Cpp :: how to cehck if list has element c++ 
Cpp :: c++std vector three elemet c++ 
Cpp :: c++ convert binary string to decimal 
Cpp :: how to get a random number between two numbers in c++ 
Cpp :: unreal get eobjecttypequery cpp´ 
Cpp :: ue4 bind function to button clicked c++ 
Cpp :: print linkedstack cpp 
Cpp :: expected number of trials to get n consecutive heads 
Cpp :: qt messagebox 
Cpp :: c++ run loop for 5 seconds 
Cpp :: how to get the player view point location and rotation in ue4 c++ 
Cpp :: __lg(x) in c++ 
Cpp :: convert a int to string c++ 
Cpp :: c++ check if file exits 
Cpp :: how to initialize 2d vector in c++ 
Cpp :: cmath sqrt 
Cpp :: cpp mst 
Cpp :: how to traverse a linked list in c++ 
Cpp :: how to copy one vector to another 
ADD CONTENT
Topic
Content
Source link
Name
2+8 =