Why are there two ways to “declare” constants in CPP?
Which is better, or should I write, which of them should I use when?
#define MYCON 100
const int MYCON=100
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.
Short rule: For conditional compilation (like different code fragments for DEBUG and RELEASE) use
#define. For all other cases useconstconstruction.