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 especially useful for complex data types. Like you have created a vector<string> grid and you need now to create an iterator for it like this
vector<string>::iterator iter = grid.begin();
that is very verbose this would achieve the same thing.
auto iter = grid.begin();
The compiler deduces the type from what you are initializing the variable with. So whatever is the type of your initializing value that will be the type of your variable.
The ranged for loop here internally initializes c with a string element, obviously that is a char so you get a char variable c.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Caesar Cipher
You are viewing a single comment's thread. Return to all comments →
auto
is especially useful for complex data types. Like you have created avector<string> grid
and you need now to create an iterator for it like thisthat is very verbose this would achieve the same thing.
The compiler deduces the type from what you are initializing the variable with. So whatever is the type of your initializing value that will be the type of your variable.
The ranged for loop here internally initializes
c
with a string element, obviously that is achar
so you get a char variablec
.