June 2018
Intermediate to advanced
348 pages
8h 45m
English
The Modern C++ language compiler does a wonderful job of deducing types from the expressions and statements specified by the programmers. Most modern programming languages do have support for type inference and so does Modern C++. This is an idiom borrowed from Functional Programming languages such as Haskell and ML. Type inferences are already available with the C# and Scala programming languages. We will write a small program to kick-start us with type inference:
//----- AutoFirst.cpp#include <iostream>#include <vector>using namespace std;int main(){ vector<string> vt = {"first", "second", "third", "fourth"}; //--- Explicitly specify the Type ( makes it verbose) for (vector<string>::iterator it = vt.begin(); ...