Consider the class definition:
```
class IntPair { int first; int second; public: IntPair(int firstValue, int secondValue); // prefix operator++ here
// postfix operator ++ here
int getFirst( ) const;
int getSecond( ) const;
};
```
a) Give declarations for prefix and postfix versions of operator++
b) Give definitions for prefix and postfix versions of operator++
a) declarations:
```
const IntPair operator++( ); //Prefix version const IntPair operator++(int); //Postfix version
```
b) definitions.
```
//prefix version
const IntPair IntPair::operator++( )
{
first++;
second++; return IntPair(first, second); }
//postfix version const IntPair IntPair::operator++(int ignoreMe) { int temp1 = first;
int temp2 = second;
first++;
second++;
return IntPair(temp1, temp2);
}
```
The traditional behavior of increment operators follows. The prefix version increments, then returns the incremented value. The postfix version saves the old value, increments the stored value then returns the old value.
You might also like to view...
In Step 3 of Business Writing, if the ________ is to make a recommendation, the recommendation needs to be expressed very clearly
Fill in the blank(s) with correct word
When ________ occurs in Project 2013, the actual progress of the project's tasks is recorded
A) setting a project baseline B) slacking C) tracking D) leveling