#include #include using namespace std; int main() { //Prefix ++i and postfix i++ increment do the same thing, //as long as they are not part of a larger expression. int i {10}; ++i; //Change i from the old value 10 to the new value 11. int j {10}; j++; //Change j from the old value 10 to the new value 11. //The subexpression ++k changes k from the old value 10 to the new //value 11. But the subexpression does more than that. //The subexpression has value of its own, which is used as part of //the larger expression that surrounds the subexpression. //The value of the subexpression ++k is 11 (the new value of k), //which is then output. int k {10}; cout << ++k << "\n"; //Outputs 11. //The subexpression h++ changes h from the old value 10 to the new //value 11. But the subexpression does more than that. //The subexpression has value of its own, which is used as part of //the larger expression that surrounds the subexpression. //The value of the subexpression h++ is 10 (the old value of h), //which is then output. //In other words, the value that we are outputting is no longer in //the variable h! The value must be in another int, somewhere. int h {10}; cout << h++ << "\n"; //Outputs 10. return EXIT_SUCCESS; }