example2_using_pair.cpp

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
#include <iostream>
#include <utility>

int main() {
    // Create a pair using std::make_pair
    auto myPair = std::make_pair(2, "Two");

    // Access the elements of the pair
    std::cout << "First: " << myPair.first << std::endl;
    std::cout << "Second: " << myPair.second << std::endl;

    return 0;
}
Back to std_pair