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
What is oops in simple words?
What is the problem with multiple inheritance?
Why oops is important?
Explain virtual inheritance?
Write a c++ program to display pass and fail for three student using static member function
What are different types of JVM's? for example we use dalvik jvm for android then what about the remaining operating systems?
Write a program to sort the number with different sorts in one program ??
What is object in oops?
What are the data types in oop?
why reinterpret cast is considered dangerous?
Why do pointers exist?
What are the two different types of polymorphism?
What is class in oop with example?
Why we use classes in oop?
How do you define social class?