Program declares the TwoWayMergeSorter<T> class template. A single member variable, tempArray, is declared. This variable is a pointer to an Array<T> instance. Since merge operations cannot be done in place, a second, temporary array is needed. The tempArray variable is keeps track of that array. The TwoWayMergeSorter constructor simply sets the tempArray pointer to zero.
Program: TwoWayMergeSorter<T> Class Definition
In addition to the constructor, three protected member functions are declared, Merge and two versions of DoSort. The purpose of the Merge function is to merge sorted subsequences of the array to be sorted. The two DoSort routines implement the sorting algorithm itself.