subject
Engineering, 15.02.2020 01:52 msalecora

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.

ansver
Answers: 2

Other questions on the subject: Engineering

image
Engineering, 04.07.2019 18:20, 3076850
Prove the equivalence between the two statements of the 2nd law of thermodynamics (i. e., a violation of one statement leads to the violatio the other statement)
Answers: 2
image
Engineering, 04.07.2019 19:10, kimmy6973
What is creep? what is stress relaxation?
Answers: 1
image
Engineering, 04.07.2019 19:10, alex6toes
What are the major differences between injection molding and extrusion?
Answers: 2
image
Engineering, 04.07.2019 19:10, batmanmarie2004
Afoot bridge is made as a simple deck, 4 m long, with a cross section 2 m (wide) and 20 cm thick, and made of wood. the deck is supported at the two ends. the maximum load allowable on the bridge is 10 tons, provided it is uniformly distributed on the deck. to sense this load, a strain gauge is placed at the center of the bridge and its resistance is monitored. if the sensor has a nominal resistance of 350 s2 and a gauge factor of 3.6, what is the reading of the strain gauge at maximum load? the modulus of elasticity for the wood used in the construction is 10 gpa.
Answers: 2
You know the right answer?
C++ Programming

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

Questions in other subjects: