example2_using_tuple.cpp

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

int main() {
    // Create a tuple using std::make_tuple
    auto myTuple = std::make_tuple(1, 3.14, "Hello");

    // Accessing the elements of the tuple
    std::cout << "First: " << std::get<0>(myTuple) << std::endl;
    std::cout << "Second: " << std::get<1>(myTuple) << std::endl;
    std::cout << "Third: " << std::get<2>(myTuple) << std::endl;

    return 0;
}
Back to std_tuple