Computer Science - Object Oriented Programming Using C++ - Discussion

Discussion Forum : Object Oriented Programming Using C++ - Section 1 (Q.No. 10)
10.
A C++ program contains a function with the header int function(double d, char c). Which of the following function headers could be used within the same program?
char function(double d, char c)
int function(int d, char c)
both (a) and (b)
neither (a) nor (b)
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
12 comments Page 2 of 2.

Ajit said:   1 decade ago
The right answer here should be (B). As the compiler differentiates the functions with same name based on.

I) No.of arguments.

II) Type of arguments.

The return type is not a taken into account in case of function overloading.

Thus (A) is ruled out.

Himanshu said:   1 decade ago
Please give a example of the same.


Post your comments here:

Your comments will be displayed after verification.