Some error occured while loading page for you. Please try again.
You are viewing a single comment's thread. Return to all comments →
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.
Thank you Siddharth.
Now its clear.
Thankyou for your time !!