Object Oriented Programming

1:

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?   

A.

Interacting with other components (like variables in an expression), in the correct way ..

B.

Flexibility to manipulate as a pointer

C.

Source code size

D.

Both (a) & (b)

 

Answer : 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 ) .

Write your comments here:


Report Error
 

Option: A

Explanation : Explanation will come here. Explanation will come here. Explanation will come here. Explanation will come here. Explanation will come here.