AIM: Write a C++ program to illustrate function overloading. Write 2 overloading functions for power.
C++ allows specification of more than one function of the same name in the same scope. These are called overloaded functions and are described in detail in Overloading. Overloaded functions enable programmers to supply different semantics for a function, depending on the types and number of arguments.
For example, a print function that takes a string (or char *) argument performs very different tasks than one that takes an argument of type double. Overloading permits uniform naming and prevents programmers from having to invent names such as print_sz or print_d. The following table shows what parts of a function declaration C++ uses to differentiate between groups of functions with the same name in the same scope.
Although functions can be distinguished on the basis of return type, they cannot be overloaded on this basis. Const or volatile are only used as a basis for overloading if they are used in a class to apply to the this pointer for the class, not the function’s return type. In other words, overloading applies only if the const or volatile keyword follows the function’s argument list in the declaration.
using namespace std;
inline float power(float x,float y)
inline int power(int x,int y)
cout<<“\n x= “<<x<<endl<<“\n y= “<<y;
x = 8
y = 9.261