Which feature of C++ allows multiple functions to have the same name but different parameter lists?
int add(int a, int b);
double add(double a, double b);
Options
-
A.
Function overriding
-
B.
Function overloading
-
C.
Function hiding
-
D.
More than one of the above
-
E.
None of the above
Correct Answer (Detailed Explanation is Below)
B.
Function overloading
Detailed Explanation
Answer: (B) Function overloading
Function overloading allows two or more functions to have the same name while having different parameter lists.
The difference may be in the number or types of parameters.
For example, add(int, int) and add(double, double) can coexist in the same program.
The compiler determines which function should be called based on the arguments supplied.