Advantages and disadvantages of using macro and inline functions?
A macro is a constant that provides straight textual substitution where used, while an inline function is a procedure that is actually called each time. Macros do have a few advantages over inline functions, but the disadvantages are numerous. For example, type checking and argument validation is not performed in a macro, while they are in functions for the most part. It is a matter that everyone should decide for themselves, but Bjarne Stroustrup, who created C++, advocates the use of inline functions over macros. Inline functions are an imperative feature of C++ and are frequently used with classes. These are no different from the normal functions except for the fact that they are never actually called. These functions are, as their name suggests, expanded in line at each point of invocation. All that needs to be done to enable or cause a function to expand at the point of invocation is to add the inline keyword before the function definition.