S
subramanian100in
Consider the code fragment:
vector<int> container;
container.insert(container.begin(), 10);
int& ref = *--container.end();
From this, it looks like we can apply prefix decrement operator to
container.end() - ie 'prefix --' can be applied to the iterator type
object which happens to be a temporary here.
In general can we apply prefix/postfix increment/decrement operator on
a temporary object of some class type ?
Kindly clarify.
Thanks
V.Subramanian
vector<int> container;
container.insert(container.begin(), 10);
int& ref = *--container.end();
From this, it looks like we can apply prefix decrement operator to
container.end() - ie 'prefix --' can be applied to the iterator type
object which happens to be a temporary here.
In general can we apply prefix/postfix increment/decrement operator on
a temporary object of some class type ?
Kindly clarify.
Thanks
V.Subramanian