list l;
auto it=l.begin();
it++; //how is this working ,as the memory is not linear
contiguous like in array
it=it+2; //but this is not working why
But in pointers this works like
int* ptr;
ptr=ptr+2;
list l;
auto it=l.begin();
it++; //how is this working ,as the memory is not linear
contiguous like in array
it=it+2; //but this is not working why
But in pointers this works like
int* ptr;
ptr=ptr+2;
Hey @Gurjot
This is so because it is an iterator and ptr is a pointer , there is a difference between the two.
Iterator only knows about where to go next(like linked list) but in case of pointer since memory is linear it can be incremented by +k where k is whole number.
I hope your doubt is resolved now .
Hey ,If your doubt is resolved then please mark it resolved 
Otherwise let me know the issue .
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.