- Increment/decrement operators can be overloaded
- Add 1 to a Date object, d1
- Prototype (member function)
- Date &operator++();
- ++d1 same as d1.operator++()
- Prototype (non-member)
- Friend Date &operator++( Date &);
- ++d1 same as operator++( d1 )
- To distinguish pre/post increment
- Post increment has a dummy parameter; int of 0
- Prototype (member function)
- Date operator++( int );
- d1++ same as d1.operator++( 0 )
- Prototype (non-member)
- friend Date operator++( Data &, int );
- d1++ same as operator++( d1, 0 )
- Integer parameter does not have a name; not even in function definition
- Return values
- Preincrement
- Returns by reference (Date &)
- lvalue (can be assigned)
- Postincrement
- Returns by value
- Returns temporary object with old value
- rvalue (cannot be on left side of assignment)
- Decrement operator analogous
2004-07-15