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
Aim: To implement a program to find area of rectangle, surface area of box and volume of box using virtual functions. Code:                       class rect {


#include #include #include #include #include class Employee { private: char *Name; //Set them as pointers... int IdNumber; char *Department; char *Position; public: voi

Threaded binary tree: Consider the linked illustration of a binary tree 'T.  Approximately half of the entries is the pointer fields 'LEFT' and 'RIGHT' will have null elements. Th

pseudocode for gregorian calendar

A string S is said to be "Super ASCII", if it contains the character frequency equal to their ascii values. String will contain only lower case alphabets (''''a''''-''''z'''') and

how to find minimum number if shelves required

6999066263304447777077766622337778 -----> message sent by the first smuggler. my name is robert---------> message decoded by the second smuggler. Where ‘0’ denotes the "space".

2. a) Define a structure to store roll no, name and marks of a student. b) Using the structure of Q2. a), above write a ''C'' program to create a file "student.dat". There must be

Want an EA project for Jack Bsher Project Description: New EA game Skills required   Android, C++ Programming, PHP, Metatrader, SQL