// pair class definition template class pair { T m_left; U m_right; public: pair(); pair(const T& t, const U& u); const T& left() const; T& left(); const U& right() const; U& right(); pair& operator+=(const pair& other); }; template pair operator+(const pair& a, const pair& b); // pair class implementation template pair::pair() { } template pair::pair(const T& t, const U& u) : m_left(t), m_right(u) { } template const T& pair::left() const { return m_left; } template T& pair::left() { return m_left; } template const U& pair::right() const { return m_right; } template U& pair::right() { return m_right; } template pair& pair::operator+=(const pair& other) { m_left += other.m_left; m_right += other.m_right; return *this; } template pair operator+(const pair& a, const pair& b) { pair dup(a); dup += b; return dup; }