What are default arguments? How are they evaluated in a C++ function?
Show answer and explanation
A default argument is substituted at the call site from declarations visible there, using the function's static type; its expression is evaluated when the call executes. Defaults are not dynamically dispatched, so combining them with virtual functions can surprise callers.
A default argument is substituted at the call site from declarations visible there, using the function's static type; its expression is evaluated when the call executes. Defaults are not dynamically dispatched, so combining them with virtual functions can surprise callers.
Connect the conclusion directly to the type, lifetime, ownership, overload-resolution rule, or library contract present in the question. State implementation dependence or a violated precondition explicitly instead of merely guessing output.