J
John Goche
A common C++ trend is to use
const int foo = 10;
where some C programmers would have used
#define FOO 10
in order to avoid preprocessor overheads.
I wonder whether it is considered ok to have the former statement
appear in header files. When making accessible a nonconst variable
in a header file I would use the extern keyword and define it in a
corresponding source file. Does this principle apply to const variables
as well or is it ok to place such definitions in source files?
Thanks,
JG
const int foo = 10;
where some C programmers would have used
#define FOO 10
in order to avoid preprocessor overheads.
I wonder whether it is considered ok to have the former statement
appear in header files. When making accessible a nonconst variable
in a header file I would use the extern keyword and define it in a
corresponding source file. Does this principle apply to const variables
as well or is it ok to place such definitions in source files?
Thanks,
JG