| |
GeekInterview.com > Interview Questions > Programming > C++
| Print | |
Question: Inline Function Advantages
Answer: What are the advantages of inline functions over macros? |
| July 07, 2009 01:33:06 |
#5 |
| AnisHasan |
Member Since: July 2009 Total Comments: 1 |
RE: Inline Function Advantages |
Beside the adventages which are mentioned there are some more advantages of Inline Functions over Macros
1> Macro call is resolve at the compile time and compiler replce Identifier with charecter sequence so it is tough to understand error Ex
#define ASPECT_RATIO 1.653
error message may refer to 1.653, not ASPECT_RATIO.
2> Some time operators get incremented two times in case of macros
#define max(a,b) ((a) > (b) ? (a) : (b))
max(++a, b); // a is incremented twice ((++a)>(b) ? (++a) :(b))
|
| |
Back To Question | |