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

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

 

Posted Date: 6/28/2013 7:02:21 AM | Location : United States







Related Discussions:- Write the program of function templates, Assignment Help, Ask Question on Write the program of function templates, Get Answer, Expert's Help, Write the program of function templates Discussions

Write discussion on Write the program of function templates
Your posts are moderated
Related Questions
When you are designing a generic class to have or otherwise manage objects of other types, when the format and behavior of those other types are unimportant to their containment or

Problem 1. Discuss polymorphism in c++. Explaining Polymorphism 2. Write a program in c++ to read a 3X2 matrix and find smallest number in that matrix. Writin

New data members  New member functions  New constructors and destructor  New friends

input marks of c and c++ if c grater than equal to 50 grater than 50 you are pass if c greater than equal to 50 c++ less than 50 than supplementry c++ if c less then 50 and c++ gra

write a program that counts the number of occurrences of the string in the n-th Padovan string P(n)   program in java // aakash , suraj , prem sasi kumar kamaraj college

#question write a prog c & cpp

In this problem you are given a board in which some of the elements are placed as shown in diagram below. Each element represents a color. Fill the other elements in the board, suc

padovan string for natural numbers program in java // aakash , suraj , prem sasi kumar kamaraj college program 1 : package test.padovanstring; public class Padov

Each function has its own stack frame between %fp and %sp. Let Caller calls Callee. Then Caller's %sp becomes callee's %fp, and callee's %sp set to be a new value (a smaller one be

Q: But MFC appear to encourage the employ of catch-by-pointer; should I do the similar? A: Depends. If you're utilizing MFC and catching one of their exceptions, by all means, d