C++ examples for Operator:Increment and decrement operators
Compare Preincrimenting and postincrementing.
#include <iostream> int main(int argc, const char *argv[]) { int c;/*from w ww.jav a2 s. co m*/ // postincrement c = 5; std::cout << c << std::endl; std::cout << c++ << std::endl; std::cout << c << std::endl; std::cout << std::endl; // preincrement c = 5; std::cout << c << std::endl; std::cout << ++c << std::endl; std::cout << c << std::endl; return 0; }