The program demonstrates the use of function templates and multiple template parameters.
#include<iostream> using namespace std; template <class T> T maximum(T x, T y) { return x>y?x:y; } template <class T,class R> void add(T x,R y) { cout<<"Adding Int Double "<<x+y<<endl; } int main() { cout<<"Integer Max "<<maximum(10,50)<<endl; cout<<"Float Max "<<maximum(10.5,5.0)<<endl; add(10.5,5); return 0; }To download raw file Click Here
Integer Max 50Float Max 10.5Adding Int Double 15.5
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions