C++ Programming - Functions - Discussion

Discussion Forum : Functions - General Questions (Q.No. 13)
13.
Which of the following statement is correct?
Only one parameter of a function can be a default parameter.
Minimum one parameter of a function must be a default parameter.
All the parameters of a function can be default parameters.
No parameter of a function can be default.
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
3 comments Page 1 of 1.

Ali said:   8 years ago
Nice question, Thanks for giving it.

Shantanu.madane said:   1 decade ago
But why not B is not correct?

Arko / Judhajit said:   1 decade ago
Yes, all the parameters or arguments of a function can be default. They can already have values, and we don't need to supply any actual arguments during the Function Call.

Even if a function has only one argument, that can be a default.

Example :

int Function(int a=0); //valid.
int Function(int a=20, int b=10); //valid.
int Function(int a, int b=10); //valid, but all parameters are not default.

Post your comments here:

Your comments will be displayed after verification.