Macros in c++ with example

Macros can be implemented using #define. When the call to the macro occurs, the code of the macro will substitute in the source code before compilation.
Syntax of the macro is

NOTE: Do not leave the space between the function and the parenthesis. The parenthesis should start immediately after the macro name.
Below is a small example:

The disadvantages of the macros are they do not perform any type of checking.
But Macros directly substitute their code, they reduce the overhead of a function call.
Let us see the below example that helps the use of the macros

Output is:

One of the common mistakes we make when we use Macro is to forget what Macro is supposed to do. In the following example, if we miss parenthesis around it, it will give us unexpected results.

The macro should be like below

To overcome the problems that are come with the macros, the only solution is inline functions