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?
Discussion:
29 comments Page 1 of 3.
Srikanth said:
1 decade ago
I think the answer A is not correct.. because default arguments must start from left..
Prabhakar said:
1 decade ago
Assignment of default values is always start from Right to left.
Sana said:
1 decade ago
The default argument can be only given from right to the left in the given parameter list!
Priya said:
1 decade ago
What are trailing arguments?
Jayati said:
1 decade ago
What is this trailing argument?
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.
Bhuvan said:
1 decade ago
@Priya & @Jayati Trailing argument means the last argument in the parameter list of function prototype.
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.
RajiSaj said:
10 years 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.
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:
10 years ago
@Anurag.
You can have more than one default arguments, all these should be at the end of the argument list.
You can have more than one default arguments, all these should be at the end of the argument list.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers