#define MAX_BALANCE 100000
const int MAX_BALANCE 100000
prefer to use const,
as pre compile phase, the MAX_BALANCE is replaced by the value(100000),
it is not made into symbol table. It's not easy to trace the value(100000), compared to variable(defined as const).
本文探讨了在C++编程中使用const和#define作为预处理宏的区别,特别是在常量值的使用上,阐述了const的优点及在预编译阶段如何被替换为具体数值,而#define则直接插入原始字符串。
485

被折叠的 条评论
为什么被折叠?



