Pick the incorrect statement about inline functions in C++.
2023
Pick the incorrect statement about inline functions in C++.
- A.
They save overhead of a return call from a function
- B.
They are generally very large and complicated function
- C.
These functions are inserted/substituted at the point of call
- D.
More than one of the above
- E.
None of the above
Attempted by 154 students.
Show answer & explanation
Correct answer: B
Inline functions in C++ are used to reduce the overhead of function calls by replacing the function call with the function body at the point of invocation. This is done by the compiler when the function is marked as 'inline'.
Option A is correct because inline functions eliminate the overhead associated with function calls, such as saving the return address and setting up the stack frame.
Option B is incorrect because inline functions are generally small and simple. Large or complex functions are not suitable for inlining as they can increase code size and may not improve performance.
Option C is correct because inline functions are substituted directly at the point of call, which is the core mechanism of inlining.
Option D is incorrect because only one statement (Option B) is incorrect, so 'more than one' is not true.
Option E is incorrect because at least one statement (Option B) is false, so 'none of the above' is not correct.
हिन्दी उत्तर: C++ में inline फ़ंक्शन फ़ंक्शन कॉल के ओवरहेड को कम करने के लिए उपयोग किए जाते हैं। ये फ़ंक्शन कॉल के स्थान पर फ़ंक्शन का शरीर डाल देते हैं।
विकल्प A सही है क्योंकि inline फ़ंक्शन फ़ंक्शन कॉल के ओवरहेड को हटाते हैं।
विकल्प B गलत है क्योंकि inline फ़ंक्शन आमतौर पर छोटे और सरल होते हैं। बड़े या जटिल फ़ंक्शन इनलाइनिंग के लिए उपयुक्त नहीं होते हैं क्योंकि वे कोड आकार बढ़ा सकते हैं और प्रदर्शन में सुधार नहीं कर सकते हैं।
विकल्प C सही है क्योंकि inline फ़ंक्शन कॉल के स्थान पर प्रतिस्थापित किए जाते हैं, जो इनलाइनिंग का मुख्य तरीका है।
विकल्प D गलत है क्योंकि केवल एक ही कथन (विकल्प B) गलत है, इसलिए 'एक से अधिक' सही नहीं है।
विकल्प E गलत है क्योंकि कम से कम एक कथन (विकल्प B) गलत है, इसलिए 'उपर्युक्त में से कोई नहीं' सही नहीं है।