0

Possible Duplicate:
Inline functions vs Preprocessor macros

In C++ the inline function qualifier basically replaces the function as a #define directive, rather than making the function being called over and over again. Thus reducing overhead time, but at the same time increasing program size.

If my understanding of inline function is correct, what is the different, of inline and #define?

Community
  • 1
  • 1

1 Answers1

2
  • inline is only a hint, which the compiler is free to ignore

  • #defines aren't a compiler-level feature—they're substitutions, not functions

    • In order to safely put multiple statements in a macro, you must wrap it in do { ... } while(0).
    • The parameters of a macro are re-evaluated every time they're used.
    • Names in the caller scope are accessible to the macro
SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964