Auto keyword usage

why it’s giving a compilation error ?

auto won’t work with array as when we do auto x : (any dataType Container) it should have a begin and an end as well , which in case of array is not defined. So to print array you have to use classic for loop but for dataType Containers like vector set map you can use auto to iterate.

@mr.encoder
but if I define a static array then auto works fine !! Then why not for dynamic ?

The real reason is this:


You can read this for better clarification.

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.