C++ | Misc C++ | Question 7

Which of the following is true about inline functions and macros.
(A) Inline functions do type checking for parameters, macros don’t
(B) Macros are processed by pre-processor and inline functions are processed in later stages of compilation.
(C) Macros cannot have return statement, inline functions can.
(D) Macros are prone to bugs and errors, inline functions are not.
(E) All of the above


Answer: (E)

Explanation: An inline function is a normal function which is defined by the keyword inline. It is a short function which is expanded by the compiler, And its arguments are evaluated only once.

An inline functions are the short length functions that are automatically made the inline functions without using the inline keyword inside the class. Inline function do type checking for parameters whereas macros do not check the parameter.

Macros are processed by pre-processor and inline functions are processed in later stages of compilation.
Macros function can not have return statement, whereas inline functions have return function. And Macros are prone to bugs and errors, inline functions are not.

So, option (E) is correct.

Quiz of this Question

My Personal Notes arrow_drop_up

Improved By : vivekkumarmth0077

Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.