Question:medium

Which of the following is not the benefit of using an inline function in C++?
(A).It can improve code readability and reduce function call overhead.
(B).It can make the code more modular and easier to maintain.
(C).It allows for dynamic function calls at runtime.
(D).It can be used to define recursive functions.
Choose the correct answer from the options given below:

Show Hint

Remember that `inline` is a compile-time suggestion to the compiler to trade a potential increase in code size for a decrease in function call overhead. It is incompatible with runtime behaviors like dynamic dispatch (virtual functions) and recursion.
Updated On: Feb 18, 2026
  • (A), (B) and (D) only.
  • (A), (B) and (C) only.
  • (A), (B), (C) and (D).
  • (B), (C) and (D) only.
Show Solution

The Correct Option is D

Solution and Explanation

Step 1: Inline Function Overview:
In C++, an inline function suggests that the compiler substitutes the function's code directly at the call site during compilation, eliminating function call overhead (stack setup, branching). The problem seeks statements that are *not* benefits of this. We interpret this as identifying statements that are false or describe limitations, not advantages, of inline functions.
Step 2: Statement Analysis:
(A) Enhances readability and reduces function call overhead: Reducing overhead is a KEY benefit. This is a TRUE benefit.
(B) Improves code modularity and maintainability: Functions, including inline functions, contribute to modularity. This is a TRUE benefit.
(C) Enables dynamic function calls at runtime: This is FALSE. Inlining occurs at compile time and *prevents* dynamic calls. Dynamic calls (e.g., virtual functions) cannot be inlined. This is a LIMITATION, not a benefit.
(D) Allows for recursive function definitions: This is FALSE. Recursive functions cannot be inlined because it would cause infinite code expansion during compilation. The `inline` keyword is ignored. This is a LIMITATION, not a benefit.
Step 3: Conclusion:
Statements (C) and (D) represent limitations. Statements (A) and (B) are benefits. The question asks for "not benefits". Therefore, (C) and (D) are the correct choices. The available options don't have a "(C) and (D) only" choice. Analyzing the answer choices, option (4): (B), (C), and (D) only is the closest. It correctly identifies (C) and (D) as "not benefits", though it also includes (B), which *is* a benefit. In the context of a flawed multiple-choice question, this is the most accurate answer, considering the potential error in including (B).
Was this answer helpful?
0


Questions Asked in CUET (PG) exam