1.

What we can’t place followed by the non-default arguments?(a) trailing arguments(b) default arguments(c) both trailing & default arguments(d) leading argumentsThe question was asked during an interview.This is a very interesting question from Default Arguments in division Functions, Namespaces & Exceptions in C++ of C++

Answer»

The correct answer is (b) default arguments

Easy explanation - To avoid the ambiguity in arguments.

eg. if func(int a=3, int b);

so if we call func(5), here will 5 will be value of a or b, because 5 is first parameter so a should be 5but as only ONE argument is given b should be 5. So to remove such ambiguity default parameters are KEPT at the END or rightmost SIDE.



Discussion

No Comment Found

Related InterviewSolutions