Functions Q.9

0. If a piece of code can be implemented as a macro or as an inline function, which of the following factors favour implementation as an inline function?

  • Option : D
  • Explanation : Macros do not have an address associated with them as they are processed by the pre-processor.
    They cannot be passed as arguments to a function, etc. Also, macros are replaced in a blind manner without any regard to the context which may result in a stupid code, like
    #define mul(a,b) a*b
    The macro call mul(a, b + 1) will be expanded as a *b+ 1, but our intention was to get a * (b+ 1 ) .
Cancel reply

Your email address will not be published. Required fields are marked *


Cancel reply

Your email address will not be published. Required fields are marked *