SHARE
SPREAD
HELP

The Tradition of Sharing

Help your friends and juniors by posting answers to the questions that you know. Also post questions that are not available.


To start with, Sr2Jr’s first step is to reduce the expenses related to education. To achieve this goal Sr2Jr organized the textbook’s question and answers. Sr2Jr is community based and need your support to fill the question and answers. The question and answers posted will be available free of cost to all.

 

#
Authors:
Walter Savitch ,julia Lobur
Chapter:
Templates
Exercise:
Self-test Exercises
Question:10 | ISBN:9780321531346 | Edition: 7

Question

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 T2; all items in the first position will be of type T1, and all items in the second position will be of type T2. 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 Heterogeneous-Pair. 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.

TextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbook

Answer

True

0 0

Discussions

Post the discussion to improve the above solution.