InterviewSolution
Saved Bookmarks
| 1. |
What do you understand by Function Overloading? |
|
Answer» Object-Oriented programming has a feature called function overloading, which allows TWO or more functions to have the same name but DISTINCT parameters. Function Overloading occurs when a function name is overloaded with several jobs. The "Function" name should be the same in Function Overloading, but the arguments should be different. Polymorphism is a feature of C++ that can be used to overload functions. An example of Function Overloading in C++ is given below: #include <bits/stdc++.h>using namespace std;VOID FOO(int N) { cout << " Integer Value: " << n << endl;}void foo(double n) { cout << " Decimal Value " << n << endl;}void foo(char n) { cout << " Character Value" << nc << endl;}int main() { foo(40); foo(452.144); foo("A"); return 0;} |
|