Difficulty: Easy
Correct Answer: The order of the default argument will be right to left.
Explanation:
Introduction / Context:
Default arguments in C++ are applied to trailing parameters that the caller omits. Practically, this means you provide actuals for the leftmost parameters and let the compiler fill in the rest using the defaults. Many MCQs summarize this as “defaults are taken from right to left.”
Given Data / Assumptions:
Concept / Approach:
Because only the rightmost parameters can be defaulted in a usable way, when a caller omits arguments, the compiler supplies defaults beginning with the rightmost parameter and moving leftward as needed. This is why declarations must place non-defaulted parameters before defaulted ones. Any attempt to default a middle parameter creates unusable or ambiguous calls and is ill-formed.
Step-by-Step Solution:
Verification / Alternative check:
Compile examples where you omit only trailing arguments; successful calls confirm the right-to-left filling. Try skipping a middle parameter; compilation fails, reinforcing the trailing rule and right-to-left mental model.
Why Other Options Are Wrong:
Left to right: contradicts the trailing-parameter rule.
Alternate or random: defaults follow a strict, deterministic rule, not arbitrary order.
Common Pitfalls:
Final Answer:
The order of the default argument will be right to left.
Discussion & Comments