Answer to Question #186382 in C++ for RAHUL SINGH

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. [


1
Expert's answer
2021-05-02T11:07:22-0400
#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!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS