Chapter 17: Problem 9
Give the definition of a template class called HeterogeneousPair that is like the class template Pair discussed in the section "Syntax for Class Templates," except that with HeterogeneousPair the first and second positions may store values of different types. Use two type parameters T1 and \(\mathrm{T} 2 ;\) all items in the first position will be of type \(\mathrm{T} 1\), and all items in the second position will be of type \(T 2 .\) The single mutator method set_element in the template class Pair should be replaced by two mutator methods called set_first and set_second in the template class HeterogeneousPair, Similarly, the single accessor method get_element in the template class Pair should be replaced by two accessor methods called get_first and get_second in the template class HeterogeneousPair.
Short Answer
Step by step solution
Key Concepts
These are the key concepts you need to understand to accurately answer the question.