previous | start | next

## Templates

- When you implement each member function, you must make it a template as indicated in syntax 17.4.

  >     template<typename T>
  >     Pair<T>::Pair(T a, T b)
  >     {
  >        first = a;
  >        second = b;
  >     }

  >     template<typename T>
  >     T Pair<T>::get_first() const
  >     {
  >        return first;
  >     }

  >     template<typename T>
  >     T Pair<T>::get_second() const
  >     {
  >        return second;
  >     }

- Each function is turned into a separate template.
- Each function name is prefixed by the "`Pair<T>::`" qualifier.
- Note the use of the type variable `T` to represent a type.

previous | start | next