C++ examples for Operator:Increment and decrement operators
Count forward several years using prefix and postfix increment operators.
#include <iostream> int main() //from w w w .j a v a 2s. c o m { int year = 2018; std::cout << "The year " << ++year << " passes.\n"; std::cout << "The year " << ++year << " passes.\n"; std::cout << "The year " << ++year << " passes.\n"; std::cout << "\nIt is now " << year << "."; std::cout << " Have the Chicago Cubs won the World Series yet?\n"; std::cout << "\nThe year " << year++ << " passes.\n"; std::cout << "The year " << year++ << " passes.\n"; std::cout << "The year " << year++ << " passes.\n"; std::cout << "\nSurely the Cubs have won the Series by now.\n"; return 0; }