type inference in C++

Type inference or type deduction refers to the automatic detection of the data type of an expression in a programming language. It is a feature present in some strongly statically typed languages. In C++, the auto keyword (added in C++ 11) is used for automatic type deduction.
The keyword auto declares an object whose type is deducible from its initializer. 
```
#include<iostream>
#include<vector>
using namespace std;
int main() {
   vector<int> arr(10);
   
   for(auto it = arr.begin(); it != arr.end(); it ++) {
      cin >> *it;
   }
   return 0;
}
```
C++11 offers a similar mechanism for capturing the type of an object or an expression. The new operator decltype takes an expression and "returns" its type:
```
const vector<int> vi;
typedef decltype (vi.begin()) CIT;
CIT another_const_iterator;
```