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...
What is the first DHCP message type sent out by a computer seeking an IP address from a DHCP server?
a. Request b. ACK c. Discover d. Offer
When you call ls with an argument (a word following ls and separated from ls by a SPACE), ls displays the name of the file named by the argument or dis- plays an error message if the file does not exist. Call ls with the name of the file created in step 1 and the string xxxx (you must separate each argument from the next by a SPACE). What happens?
What will be an ideal response?
Which of these tags would most likely be used in HTML to view a multimedia element on the Web?
a.
b.