The Pair class
You will be writing this class from scratch. It will have the following methods:
- Pair(): a default constructor that does nothing.
- Pair(int first, int second): a 2-arg constructor that creates a pair with the given values
- GetFirst(): an accessor that returns the value of the first member of the pair.
- GetSecond(): 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 overloading "==" as a member functions:
Function declaration to put inside the Pair class definition:
bool operator== (const Pair& rhs) const;
and for the actual 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 */ }(Note that these are for the non-templated version; they will have to be updated to work in a template.)
You should first implement Pair as a plain class, with int as the data type for the members. When you've done that, you can compile it with Lab13.cpp as given to test it.
Note that you should design the file structure like a templated class: have Lab13.cpp #include Pair.h (which it does), then have Pair.h #include Pair.cpp at the very bottom, and wrap the whole thing in #ifdef PAIR_H guards.
Once testing of the simple class is done, you should upgrade
it to be a templated class. Then, delete the pair1-pair4 declarations
at the top of Lab13.cpp, and uncomment the Pair