auto keyword in c++ code example
Example 1: auto in c++
int foo = 0;
auto bar = foo; // the same as: int bar = foo;
// type of bar is the type of the value used to initialize it
Example 2: auto in cpp
#include<iostream>
#incllude<vector>
using namespace std;
int main() {
vector<int> vec(10); // Auto deduce type to be iterator of a vector of ints.
for(auto it = vec.begin(); it != vec.end(); vec ++)
{
cin >> *it;
}
return 0;
}