Question #186382

Write a program which has a class template for determining the largest and the smallest number

from a list of numbers. Use a constructor for input and appropriate data members and member

functions in support of your answer. [


Expert's answer

#include <iostream>
using namespace std;
 

template <typename T>
T myMax(T x, T y)
{
   return (x > y)? x: y;
}
 
int main()
{
  cout << myMax<int>(3, 7) << endl; 
  cout << myMax<double>(3.0, 7.0) << endl; 
  
 
  return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

LATEST TUTORIALS
APPROVED BY CLIENTS