write a c++ program to find maximum of two numbers using
inline functions.
Answer Posted / ada
#include <iostream>
using namespace std;
template<typename T>
inline T& max(T& x, T& y)
{
return x>y ? x:y;
}
int main()
{
char bx = 'a', by = 'b';
int ix = 1, iy = 2;
float fx = 1.5, fy = 2.5;
double dx = 2.5, dy = 1.5;
cout<<"char max:"<<max(bx, by)<<endl;
cout<<"int max:"<<max(ix, iy)<<endl;
cout<<"float max:"<<max(fx, fy)<<endl;
cout<<"double max:"<<max(dx, dy)<<endl;
return 0;
}
Is This Answer Correct ? | 39 Yes | 33 No |
Post New Answer View All Answers
How to call a non virtual function in the derived class by using base class pointer
What is super in oop?
2. Give the different notations for the class.\
i got a backdoor offer in process global,Bangalore..Can i work with it?
Why polymorphism is used in oops?
What is the difference between static polymorphism and dynamic polymorphism?
Write a c++ program to display pass and fail for three student using static member function
Advantage and disadvantage of routing in telecom sector
Why is static class not inherited?
explain sub-type and sub class? atleast u have differ it into 4 points?
hi all..i want to know oops concepts clearly can any1 explain??
When not to use object oriented programming?
What is polymorphism and types?
What is encapsulation in ict?
What is pointer in oop?