C++ Programming - Functions - Discussion

Discussion Forum : Functions - General Questions (Q.No. 14)
14.
Which of the following statement is incorrect?
A default argument is checked for type at the time of declaration and evaluated at the time of call.
We can provide a default value to a particular argument in the middle of an argument list.
We cannot provide a default value to a particular argument in the middle of an argument list.
Default arguments are useful in situations where some arguments always have the same value.
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
4 comments Page 1 of 1.

Manasa said:   1 decade ago
There are certain rules for providing default values to arguments:

(1) You cannot have a default argument followed by non default argument.

(2) If you default an argument then you will have to default all the subsequent arguments after that.

(3) You cannot have a default argument in the middle of the list.
(1)

Himanshu said:   1 decade ago
Yes Answer (B) is correct because default value can be provided to the trailing of the argument list.

Mannu said:   1 decade ago
What is training ?

Kirk said:   10 years ago
Statement B is too vague. Take a look at this function:

int func1 (int parm1=10, int param2=20, int param3=30);

There - I just provided a default value to the middle parameter.

I would reword it to this statement:

We can provide a default value to a particular argument in the middle of an argument list where any following arguments do not have a default value.

Post your comments here:

Your comments will be displayed after verification.