// CSE333 14wi final exam - pair class header file
// sample solution

#include <iostream>
#include <string>

using namespace std;

#ifndef _Pair_h_
#define _Pair_h_

// simple pair class that defines element-wise addition on pairs
template <class T>
class Pair {
public:
  // Construct new pair with given first and second values
  Pair(T first, T second) : first_(first), second_(second) { }

  // accessors: return first and second items from pair
  T first()  const { return first_;  }
  T second() const { return second_; }

  T munge() const; // !!!!

  // return a new Pair that is the element-wise sum of its arguments
  Pair<T> operator+(const Pair<T> &other) const {
    return Pair<T>(
        first_ + other.first_,
        second_ + other.second_);
  }

  // copy assignment
  Pair<T> &operator=(const Pair<T> &rhs); // !!!!

private:
  // instance variables: two values of type T
  T first_, second_;
};

// print pair contents to cout
template <class T>
ostream& operator<<(ostream& o, const Pair<T> &p) {
  o << "(" << p.first() << ", " << p.second() << ")";
  return o;
}

#endif  // _Pair_h_