#include <iostream>
using namespace std;
void Display(int i, char const *c)
{
cout << " Here is int " << i << endl;
cout << " Here is char* " << c << endl;
}
void Display(double f)
{
cout << " Here is float " << f << endl;
}
int main()
{
Display(5,"Five");
Display(5.5);
return 0;
}
Output:
Here is int 5
Here is char* Five
Here is float 5.5
2. The data types of the parameters of functions.
#include <iostream>
using namespace std;
void Display(int i)
{
cout << " Here is int " << i << endl;
}
void Display(double f)
{
cout << " Here is float " << f << endl;
}
void Display(char const *c)
{
cout << " Here is char* " << c << endl;
}
int main()
{
Display(5);
Display(5.5);
Display("Five");
return 0;
}
Output:
Here is int 5
Here is float 5.5
Here is char* Five
3. The order of the parameters of functions.
#include <iostream>
using namespace std;
void Display(int i, char const *c)
{
cout << " Here is int " << i << endl;
cout << " Here is char* " << c << endl;
}
void Display(char const *c,int i)
{
cout << " Here is int " << i << endl;
cout << " Here is char* " << c << endl;
}
int main()
{
Display(5,"Five");
Display("Five",5);
return 0;
}
Answer:
Function overloading can be done by changing:
1.The number of parameters in two functions.
Output:
2. The data types of the parameters of functions.
Output:
3. The order of the parameters of functions.
Output: