what is the difference between const and # define function and where it can be used | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

what is the difference between const and # define function and where it can be used

27th Jan 2019, 7:17 AM
SaiRam
SaiRam - avatar
2 Answers
+ 2
define is checked by preprocessor. const by compiler. So define changes all variables to the defined ones, but const we only call the value.
27th Jan 2019, 7:40 AM
ShortCode
+ 1
const is for declaring a constant, it prevents you from modifying a variable for example. #define basically does a text search and replace.
27th Jan 2019, 9:53 AM
Zen
Zen - avatar