C++ Programming - Functions - Discussion

Discussion Forum : Functions - General Questions (Q.No. 9)
9.
Which of the following function declaration is/are incorrect?
int Sum(int a, int b = 2, int c = 3);
int Sum(int a = 5, int b);
int Sum(int a = 0, int b, int c = 3);
Both B and C are incorrect.
All are correct.
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
15 comments Page 2 of 2.

Raksha G said:   9 years ago
Correct answer is A because default arguments should start from right.
(2)

Bipul said:   8 years ago
Here we have to find which are incorrect that's why option B and C are in correct. Option D is the answer. And option A is correct.

Mirza Waseem Hussain said:   5 years ago
If you assign default value to an argument, the subsequent arguments must have default values assigned to them, else you will get compilation error.
(4)

Dharmi said:   5 years ago
Why option B is incorrect?

Santosh kumar yadav said:   11 months ago
I think inc sum(int a = 0 ,int b int c =3) is the correct answer.


Post your comments here:

Your comments will be displayed after verification.