DECLARATION OF CONSTANT

hi guys,
just a very simple question...
for a constant declaration like this: CONST int period_of_no_buy = 5;
should i put this declaration in my header file or my implementation file?
thanks.
regards,
Bosco
If you may need it outside of the implementation file in question, put it in your header file. If that isn't the case, put it in the implementation file.
hmm... what if i have three implementation files and all the three implementation files need the constant?
Declare it extern in all of them except for one, and actually define it in the last.
It's a constant. As long as you're using it as a literal constant, there is no reason to declare it extern although static may be indicated, and certainly defining it in only one implementation file destroys the possibility of the compiler treating it as a compile-time constant in the other implementation files.

Last edited on
Topic archived. No new replies allowed.