Why does the next program prints 1 instead of 4?
std::vector<int> v;
v.push_back(1);
v.push_back(4);
std::vector<int>::iterator it = v.begin();
int n = *(it++);
std::cout << n;
The pre/post increment operator is part of an expression that evaluates to a value (and has a side effect of changing the variable being incremented.)
Evaluation of prefix increment (++i) is increment variable, return new value
Evaluation of postfix increment (i++) is increment variable, return original value
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.