We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
auto is a feature new in C++11 onward. It allows the type of the variable to be inferred from its initilizer statement. For example:
inti=3;autoj=i;autok=10;
Instead of specifying int for j and k, you can use auto, and the compiler will try to infer the type that j and k should be.
It's especially useful when using iterators, as they can be quite long type specificers such as vector<string>::iterator. It's also useful when code changes and if the code was previously using auto then less has to be modified to be updated.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Strings: Making Anagrams
You are viewing a single comment's thread. Return to all comments →
auto
is a feature new in C++11 onward. It allows the type of the variable to be inferred from its initilizer statement. For example:Instead of specifying
int
forj
andk
, you can useauto
, and the compiler will try to infer the type thatj
andk
should be.It's especially useful when using iterators, as they can be quite long type specificers such as
vector<string>::iterator
. It's also useful when code changes and if the code was previously usingauto
then less has to be modified to be updated.