Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

What is class encapsulation?

1030


How to call a non virtual function in the derived class by using base class pointer

6420


i=20;k=0; for(j=1;k-i;k+=j<10?4:3) { cout<

1810


What are different types of JVM's? for example we use dalvik jvm for android then what about the remaining operating systems?

2079


What is object and example?

1113


What is the advantage of oop over procedural language?

1006


What are the 4 main oop principles?

1162


What is the real time example of inheritance?

1079


What is meant by multiple inheritance?

1180


What do you mean by variable?

974


What is polymorphism oop?

1008


what type of question are asked in thoughtworks pair programming round ?

2145


class CTest { public: void someMethod() { int nCount = 0; cout << "This is some method --> " << nCount; } }; int main() { CTest *pctest; pctest->someMethod(); return 0; } It will executes the someMethod() and displays the value too. how is it possible with our creating memory for the class . i think iam not creating object for the class. Thanks in Advance... Prakash

2224


Why is abstraction used?

1028


hi all..i want to know oops concepts clearly can any1 explain??

2081