The Pair class
The first step is to write a non-templated Pair class. The class must have the following methods:
- Pair(): a default constructor that does nothing.
- Pair(int first, int second): a two-argument constructor that creates a pair with the given values.
- first(): an accessor that returns the value of the first member of the pair.
- second(): an accessor that returns the value of the second member of the pair.
- operator==(): overload the equality operator to compare two pairs in a position-independent fashion (i.e., the first and second can match in any order).
As a reminder, here is the syntax for declaring the overloaded "==" operator:
bool operator== (const Pair& rhs) const;and the syntax for the function definition:
bool Pair::operator== (const Pair& rhs) const { /* Code here to see if first==first and second==second, * OR first==second and second==first */ }
Once you have completed the non-templated version of the Pair class, compile it with lab11.cpp to test it:
g++ -Wall -ansi lab11.cpp Pair.cpp -o lab11