Question
Option 2 : Compilation error — ambiguous call / कंपाइलेशन त्रुटि — अस्पष्ट कॉल
Detailed Solution
सही उत्तर Compilation error — ambiguous call / कंपाइलेशन त्रुटि — अस्पष्ट कॉल है।
Question:
Consider the C++ declarations `void f(int a, int b = 5);` and `void f(int a);`. What does the call `f(10);` do? / C++ घोषणाओं `void f(int a, int b = 5);` और `void f(int a);` पर विचार करें। कॉल `f(10);` क्या करेगा?
Correct Answer: Compilation error — ambiguous call / कंपाइलेशन त्रुटि — अस्पष्ट कॉल
Both overloads are viable for a single `int` argument and neither is better, so overload resolution fails with an ambiguity error at compile time. The trap is assuming the default argument or the exact-arity overload automatically wins. / एक `int` आर्गुमेंट के लिए दोनों overload उपयुक्त हैं और कोई बेहतर नहीं है, अतः overload resolution कंपाइल समय पर ambiguity त्रुटि देता है। जाल यह मानना है कि default argument या exact-arity वाला overload स्वतः जीत जाता है।