1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <iostream>
#include <array>
int main() {
std::array<int, 3> myArray = {10, 20, 30};
std::cout << "First element: " << std::get<0>(myArray) << std::endl;
std::cout << "Second element: " << std::get<1>(myArray) << std::endl;
std::cout << "Third element: " << std::get<2>(myArray) << std::endl;
// Modifying an element
std::get<1>(myArray) = 25;
std::cout << "Modified second element: " << std::get<1>(myArray) << std::endl;
return 0;
}
Back to std_get