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. [
#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;
}
Comments
Leave a comment