Overloading the Prefix Increment Operator

Suppose that we want to add 1 to the day in Date object d1. When the compiler sees the preincrementing expression ++d1, the compiler generates the member-function call

d1.operator++()

The prototype for this operator member function would be

Date &operator++();

If the prefix increment operator is implemented as a non-member function, then, when the compiler sees the expression ++d1, the compiler generates the function call

operator++( d1 )

The prototype for this non-member operator function would be declared as

Date &operator++( Date & );

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.119.192.55