Let us take:
x = list<int>::iterator
y = list<int>::const_iterator
z = vector<int>::iterator
t = vector<int>::const_iterator
Is there any difference between:
++x
andx++
?++y
andy++
?++z
andz++
?++t
andt++
?
++x is more efficient than x++, because x++ creates a temporary object first.
Also, There will be a difference if you use it in an assignment statement as you do for let say an integer
int x = 8;
int y;
y = x++;//y will be 8
y = ++x;//y will be 10
Similarly if you access iterators like this, pre increment will point to the next iterator first and then do other operation. If post increment, then the current will be accessed and then will be incremented.