Programming in c++ PREFⅨFoRM Increment Operator int age, 8 age = 8 ade +tage, age 16
16 PREFIX FORM Increment Operator 8 int age; age = 8; ++age; age 9 age
Programming in c++ POSTFIX FORM Increment Operator int age; 8 age =8 ade age++, age 17
17 POSTFIX FORM Increment Operator 8 int age; age = 8; age++; age 9 age
Programming in c++ Decrement Operator int dogs 100 dogs = 100 dogs dogs--; 99 dogs 18
18 Decrement Operator 100 int dogs; dogs = 100; dogs--; dogs 99 dogs
Programming in c++ Which Form to Use? %when the increment(or decrement) operator is used in a stand alone statement solely to add one(or subtract one) from a variable's value, it can be used in either prefix or postfix form USE EITHER dogs--, dogs i 19
19 Which Form to Use? vwhen the increment (or decrement) operator is used in a “stand alone” statement solely to add one (or subtract one) from a variable’s value, it can be used in either prefix or postfix form dogs-- ; --dogs ; USE EITHER
Programming in c++ BUT when the increment(or decrement) operator is used in a statement with other operators, the prefix and postfix forms can yield different results WELL SEE HOW LATER.. (In Chapter 10)
20 BUT... vwhen the increment (or decrement) operator is used in a statement with other operators, the prefix and postfix forms can yield different results WE’LL SEE HOW LATER . . .(In Chapter 10)