Question: #include #include using namespace std; /*** Template class Pair ***/ template typename TheType> class Pair { public : void Input(); void Output(); char CompareWith(Pair *

 #include #include using namespace std; /*** Template class Pair ***/ templatetypename

#include

#include

using namespace std;

/*** Template class Pair ***/

templatetypename TheType> class Pair {

public:

void Input();

void Output();

char CompareWith(Pair* otherPair) ;

void ShowComparison(Pair* otherPair);

private:

TheType firstVal;

TheType secondVal;

};

// Return '' according to whether the Pair is less than,

// equal to, or greater than the argument Pair

templatetypename TheType>

char Pair::CompareWith(Pair* otherPair) {

/* Type your code here. */

}

// Input values into a pair

templatetypename TheType>

void Pair::Input() {

/* Type your code here. */

}

// Output a Pair

templatetypename TheType>

void Pair::Output() {

/* Type your code here. */

}

// Output both pairs with a comparison symbol in between

templatetypename TheType>

void Pair::ShowComparison(Pair* otherPair) {

/* Type your code here. */

}

/*** End template class Pair ***/

int main() {

Pairint> intPair;

Pairint> intOtherPair;

intPair.Input();

intOtherPair.Input();

intPair.ShowComparison(&intOtherPair);

Pairdouble> doublePair;

Pairdouble> doubleOtherPair;

doublePair.Input();

doubleOtherPair.Input();

doublePair.ShowComparison(&doubleOtherPair);

Pair wordPair;

Pair wordOtherPair;

wordPair.Input();

wordOtherPair.Input();

wordPair.ShowComparison(&wordOtherPair);

return 0;

}

Please complete this code above in C++

Complete template class Pair by defining the following methods: 1. void Input() - Read two values from input and initialize the data members with the values in the order in which they appear 2. void Output( - Output the Pair in the format "[firstVal, secondVal]" 3. char CompareWith(Pair* otherPair) - Return the character ' ' according to whether the Pair is less than, equal to, or greater than otherPair - Precedence of comparisons is firstVal then secondVal 4. char ShowComparison(Pair* otherPair) - Compare with otherPair by calling CompareWith 0 - Output the two Pairs separated by the character returned by CompareWith(). Hint: Output each Pair using Output() Note: For each type main() calls Input() twice to create two Pairs of that type. Ex: If the input for two Integer Pairs is: 4635 the first Pair is [4,6], and the second Pair is [3, 5]. Ex: If the input of the program is: 46634.3onetwothreefour52.14.32.1 the output is: [4,6]>[3,5][4.3,2.1]=[4.3,2.1][one,two]

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!