Under what circumstance is it impossible to assign a default value to a parameter while declaring a function?
-
When the parameter is Boolean
-
When the function is being declared as a member of a class
-
When the parameter is being declared as passed by reference
-
When the function contains only one parameter
Default values for function parameters (using '= value') are syntactically valid in C++ for primitive types (like Boolean) and class methods. However, they generally cannot be used for parameters passed by reference unless the reference is to a const type (e.g., 'const int&'). As the option implies a non-const reference (standard modifiable reference), this is the circumstance where a default argument is typically invalid or nonsensical.
When a parameter is declared to be passed by reference, it cannot be given a default value, because a reference must be bound to an actual existing variable at call time, not a literal or temporary default. This is why languages like PHP and C++ restrict default values on reference parameters. The other options (Boolean type, member of a class, single-parameter function) do not create this restriction.