I have the following program:
#include <iostream>
using namespace std;
int main()
{
int array[] = {1, 2, 3};
int a = array[0],
b = array[1],
c = array[2];
cout << c << endl;
}
This prints 3, so far so good. But I wonder if there is a more elegant syntax for declaring multiple variables from an array at once. For example (just an idea, does not compile):
int [a, b, c] = array;
Is there any feature like this in C++ or one of the new standards? I can't be the only one looking it.
Alternatively: what is your most elegant way to set multiple variables from an array at once?
std::tieclassorstructis more appropriate.