C++ Programming - Functions - Discussion

Discussion Forum : Functions - General Questions (Q.No. 3)
3.
Which of the following statement is correct?
Overloaded functions can have at most one default argument.
An overloaded function cannot have default argument.
All arguments of an overloaded function can be default.
A function if overloaded more than once cannot have default argument.
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
15 comments Page 2 of 2.

Purvi said:   9 years ago
That means the answer is incorrect, because when we call the function, it is differentiated by the different argument type, that is only overloading.

Can someone give a reason?
(1)

Pradhnya said:   9 years ago
I think option B is the correct answer.

Pradnya said:   9 years ago
@Pradhnya.

Only option c is correct answer because it says//*All arguments of an overloaded function "CAN BE " default*// means that It does not matter weather the parameter is default or not.

Vignesh mahendran said:   8 years ago
void fun(int a=10,int b=20);
void fun();
main()
{
fun();
}

So, error will occur.

Priya said:   7 years ago
I think that option B is correct because the overloaded function should be varied in type and number of argument, in that case, if we declare a function with default argument, the compiler gets confused to execute the correct function.
(1)


Post your comments here:

Your comments will be displayed after verification.