September 2017
Beginner to intermediate
384 pages
8h 4m
English
You can now initialize multiple variables with a return value with a really cool syntax, as shown in the following code sample:
#include <iostream>#include <tuple>using namespace std;int main ( ) { tuple<string,int> student("Sriram", 10); auto [name, age] = student; cout << "\nName of the student is " << name << endl; cout << "Age of the student is " << age << endl; return 0;}
In the preceding program, the code highlighted in bold is the structured binding feature introduced in C++17. Interestingly, we have not declared the string name and int age variables. These are deduced automatically by the C++ compiler as string and int, which makes the C++ syntax just like any modern programming language, without losing its performance ...