That code printed numbers in the list. Actually that's what I intended. But suddenly I realized that a list is much more than a sequnece of numbers. Where are those pointers to previous and next node. Why didn't they get printed? How does cout know not to print them?
So a data structure contains our main data and also some auxiliary data required to maintain the structure itself. Dereferencing operator on an iterator is written in a way to return only the 'main' data.
I think I understood iterator invalidation also. As long as the structure of the data structure remains unchanged, iterators don't get invalidated.