Question: C++ Programming Create a class template Pair that houses 2 items of datatype T. Whatever datatype stored needs to implement the < and > operators.

C++ Programming

Create a class template Pair that houses 2 items of datatype T.

Whatever datatype stored needs to implement the < and > operators.

There should be two private data attributes called item1 and item2.

There should be the following public methods.

A 2 argument constructor.

A method getMax that returns the larger of the two stored items.

A method getMin that returns the smaller of the two stored items.

A method setItems that takes in two constant items by reference and sets item1 and item2 to them.

A method getItem1 that returns item1.

A method getItem2 that returns item2.

Make a appropriate methods const so they don't alter item1 or item2 if not needed.

You should have a Pair.h and Pair.cpp file.

Create a pairTest.cpp file with a main() that creates two pairs, one that houses ints an one that houses strings.

Test all the methods for these two Pairs in your main and display the results.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!