Question #293127

Create a function Maximum using templates, your function should have the following prototype

t Maximum (t x, t y)

This function should return the maximum values out of the two values being passed, in your main function create variables of different types, integer, character and double and check what your function returns for each different variable type. 


Expert's answer

#include <iostream>
#include <string>
using namespace std;


template<typename t>
t Maximum (t x, t y){
	if(x>y){
		return x;
	}
	return y;
}




int main(){
	cout<<"Maximum(4,6): "<<Maximum(4,6)<<"\n";
	cout<<"Maximum(n,a): "<<Maximum('n','a')<<"\n";
	cout<<"Maximum(45.65,25.6): "<<Maximum(45.65,25.6)<<"\n";


	system("pause");
	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