#include <iostream>
#include <array>
#include <tuple>
using namespace std;
int& getValue(int x) {
int value = x * 2;
return value;
}
int& getArr(std::array<int, 100>& my_array, int ix) {
return my_array[ix];
}
std::tuple<int, double> getTuple(){
int a = 10;
double d =3.14;
return std::make_tuple(a, d);
}
int main() {
int & value = getValue(3);
cout << value << endl;
std::array<int, 100> my_array;
my_array[30] = 10;
getArr(my_array, 30) = 1024;
cout << my_array[30] << endl;
/////////////////////////////////////////////////////////////////
std::tuple<int, double> my_tp = getTuple();
cout << std::get<0>(my_tp) <<endl;
cout << std::get<1>(my_tp) << endl;
/////////////////////////////////////////////////////////////////
auto [a, d] = getTuple(); //C++17에서 가능
cout << a << endl;
cout << d << endl;
return 0;
}
코딩/C++