What is the return type of an iterator? why we used auto here?

What is the return type of an iterator? why we used auto here?

@riagoel3999 , auto basically takes the data type automatically if data type is integer then auto will become int
iterator is like a pointer

1 Like

What is the datatype of iterator here?

@riagoel3999, pointer thats y u r using *it to get the value

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

like auto i =9;
here i is integer. If I write string s; auto it=s.begin();here it is?

pointing to the first character of string

so it is of type char
I can write char it=s.begin() that means?

no its string iterator, defined in string class…u can write string:: iterator it