Auto redefined in c++ 11

In previous versions of c++ auto was just a storage class specifier, which can be used for declaring variables of local scope. By default all the variables were treated as auto. So the “auto” keyword was rarely used. In c++ 11 , auto makes programmers life, a bit easier. Just like PHP or any other modern language, auto now enables us to declare variables without thinking much about the type of data .  But do remember to initialize the variables while declaring.

A>     auto x = 23;  // will create an integer with value 23

B>     double f() ;

auto d = f() ; // here f is double

C>    vector<int> m;

auto it = m.end(); // here it is of type “vector<int>::iterator”




Leave a Reply

Your email address will not be published. Required fields are marked *