When I took my first university programming class, my professor taught us to define constants using #define. It's a practice that should not be used in production code, to write robust, modern C++, you need to understand the distinct roles of #define, const, and constexpr.
While they may seem interchangeable, these three tools operate at different stages of the program's lifecycle, understanding the difference between the Preprocessor, Compile-time and Runtime is the key to choosing the right one.
1.- The Macro #define
This directive is a C heritage, it is a preprocessor directive, not a C++ language feature. When it is used, you are not defining a constant, you are telling the preprocessor to perform a blind text replacement before the compiler even sees your code.
Why you must stop using it?






