In C++ you do not use macros.
Macros have been replaced by these C++ features:
1) inline functions
2) templates
3) enums
4) namespaces.
The problem with macros is that the macro is expanded by the preprocessor wo what is compiled is not what is in your source code. If the macro expansion causes problems, your debugger is useless since there is no code to debug. Should to get problem like this, you have to stop be build after the proeprocessor is finished and before the compiler executes annd verify by eyeball (a very relaible method) each and every macro expansion to see if it was done correctly.
The only place in C++ where a macro is used is in the inclusion guards of header files:
-
#ifndef MYHEADER
-
#define MYHEADER
-
...header file contents...
-
#endif
-
C does not have these features so C programmers use macros all the time. When these programmers learn C++, they bring their bad habits into the C++ code and riddle it with macros which propagates the problems they had in C.