Possible Duplicate:
“static const” vs “#define” in c
In C are symbolic constants defined at compile time or runtime?
Whats the difference between symbolic constant:
#define GOKU 9111
vs const variables
int const GOKU = 9111;
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
A
defineis simply a text replacement. Aconstis read-only memory. For instance, you can’t say&GOKUif it’s a define.EDIT
I forgot about type checking and scoping. Using
constis sometimes better than using adefinesince the compiler can check the types if you involve the constant in an operation. Alsoconstobeys scopes so it won’t pollute your namespace.