Function Overloading In C++
Function
overloading is a feature in C++ where two or more functions can have the same
name but different parameters.
Fig: Function Overloading In C++
Fig: Function Overloading In C++
Program:
#include <iostream>
#include<conio.h>
void print(int i) {
cout << " Here
is int " << i << endl;
}
void print(double f) {
cout << " Here
is float " << f << endl;
}
void print(char const *c)
{
cout << " Here
is char* " << c << endl;
}
void main() {
print(10);
print(10.10);
print("ten");
getch();
}
Output:
Here is int 10
Here is float 10.1
Here is char* ten
No comments:
Post a Comment