C++ Programming - Functions - Discussion

Discussion Forum : Functions - General Questions (Q.No. 5)
5.
Which of the following statement will be correct if the function has three arguments passed to it?
The trailing argument will be the default argument.
The first argument will be the default argument.
The middle argument will be the default argument.
All the argument will be the default argument.
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
30 comments Page 3 of 3.

Madhu said:   1 decade ago
What is mean by trailing argument?

RajiSaj said:   1 decade ago
Only the argument at the end of the argument list can have default arguments.

Because if you insert the default arguments at the middle of the argument list, the compiler would lose track of what arguments went where.

void badfunc(int, int=2,int) // Wrong way...

void okfunc(int, int=2, int=5); // Correct.

Raji Saj said:   1 decade ago
@Anurag.

You can have more than one default arguments, all these should be at the end of the argument list.

Anurag Kumar said:   1 decade ago
If a function has three arguments then it is not necessary that the trailing argument will be default argument.

Bhuvan said:   1 decade ago
@Priya & @Jayati Trailing argument means the last argument in the parameter list of function prototype.

Naresh punia said:   1 decade ago
If you have not defined default argument in function definition then there will be no default argument. By the way default argument always come in RHS of argument list.

Jayati said:   1 decade ago
What is this trailing argument?

Priya said:   1 decade ago
What are trailing arguments?

Sana said:   1 decade ago
The default argument can be only given from right to the left in the given parameter list!

Prabhakar said:   1 decade ago
Assignment of default values is always start from Right to left.


Post your comments here:

Your comments will be displayed after verification.