Difference Detween #define and Const

One is a preprocessor directive and one is a compiler directive

 

When you use const, the compiler will do appropriate checks during the compile time. So, it's better to use const instead of #define, wherever possible.

 

Also, #define gets substituted in the code by its value, thus increasing the size of executable. When you use const, this is not the case.

Ebook Download
View all
Learn
View all