Write the program of function templates, C/C++ Programming

Assignment Help:

Consider the following example:

int max(int x, int y)

                 {

                                return ( x > y) ? x : y ;

                 }

 

float max(float x, float y)

                 {

                                return ( x > y) ? x : y ;

                 }

 

 long max( long x,  long y)

                 {

                return ( x > y) ? x : y ;

                 }

 

char max(char x, char y)

                 {

                                return ( x > y) ? x : y ;

                 }

                void main()

                {

                  cout << max( 1,2) << endl;

                  cout << max( 4L,3L) << endl;

                  cout << max( 5.62,3.48) << endl;

                  cout << max('A','a') << endl;

                }


The output is :

                                                2

                                                4

                                                5.62

                                                a

 


Related Discussions:- Write the program of function templates

AlgorithmS, Algorithm to find the value of the powers raised by integer

Algorithm to find the value of the powers raised by integer

Inheitance, ambiguity in multiple inheritance

ambiguity in multiple inheritance

Problem : Change to palindrome, A palindrome is a string that reads the sam...

A palindrome is a string that reads the same from both the ends. Given a string S convert it to a palindrome by doing character replacement. Your task is to convert S to palindrome

How virtual functions can be implemented in c++?, Normal 0 fals...

Normal 0 false false false EN-US X-NONE X-NONE

C, Write a program to find the area under the curve y = f(x) between x = a ...

Write a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b. The area under a curve between two points can b

Write a fragment of code that declares a variable, (a) Write a fragment of ...

(a) Write a fragment of code that declares a variable colSp of type ColourSpot, and then moves it to the point (3, -4), and sets its colour to Green. (b) A function QU8 is speci

Advance in c, create a program to populate the first array then the odd num...

create a program to populate the first array then the odd number is the second array and get the sum of the second array.

Area, write a program to find area of curve y=f(x) between x and x=b,integr...

write a program to find area of curve y=f(x) between x and x=b,integrate between the limits a and b using c     #include float start_point, /* GL

File IO, I''m trying to write a function that prints the substring if it is...

I''m trying to write a function that prints the substring if it is found in the string, and after it prints it deletes it from the string so i could print the next substring if it

Program of binary tree, Program of Binary tree: Btree::Btree(int O) : ...

Program of Binary tree: Btree::Btree(int O) : itemsInContainer(0) {     finishInit(O); }   Btree::~Btree(void) {     if( root != 0 )         delete roo

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd