Saturday, October 18, 2008

Const vs. #define

Advantages of const over #define. When to use which of them?

hints:
const means the data can't be changed while define has no such meaning.
const is used by compiler and define is performed by pre-processor.
const has scope while define can be considerd global.
const variable can be seen from debugger while macro can be seen.
const guarantee the type which macro can't

No comments: