1.

Default arguments are _________________________(a) Only allowed in the parameter list of the function declaration(b) Only allowed in the return type of the function declaration(c) Only allowed with the class name definition(d) Only allowed with the integer type valuesI have been asked this question in a job interview.My doubt is from Default Arguments topic in chapter Default Arguments vs Overloading, Upcasting and Downcasting of Object Oriented Programming

Answer»

The CORRECT option is (a) Only allowed in the parameter list of the FUNCTION declaration

Explanation: The default arguments are only allowed in the parameter list of the function arguments. This rule was not applicable in the BEGINNING versions of c++ but LATER from c++ 14th version it has been implemented. This is the only way to USE default arguments.



Discussion

No Comment Found

Related InterviewSolutions