example1_basic_usage.cpp

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
#include <iostream>
#include <utility>  // For std::pair

int main() {
    // Create a pair to store an integer and a string
    std::pair<int, std::string> myPair(1, "One");

    // 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