Default arguments are _________________________ A. Only allowed

default-arguments-are-a-only-allowed

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 values

I 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

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.