When to use constexpr and when to use extern const?
I have a situation like:
in header (.h):
extern const int MAX_NUMBER_OF_ROWS;in source (.cpp):
const int MAX_NUMBER_OF_ROWS= 99;
The files (header and source) contains just such definitions and declarations.
Is it recommanded to use just the constexpr in the header file and get rid of the source file, like in here?:
// this is in the header file. There is no cpp file any more. constexpr int MAX_NUMBER_OF_ROWS= 99;
const int MAX_NUMBER_OF_ROWS = 99;in the header; and then the question would be whether to changeconsttoconstexpr. Having it the way you have it is usually only done if the value is not known at the time of the header being includedconstexpr, right?