If I have a class that contains only compile-time constants, for example,
class A {
static const int x = 1;
static const int y = 2;
static const int z = 3;
};
I believe that if the address of the constants is not accepted, they can (will?) Be replaced at compile time, when they are used, and will not occupy space in the executable file (that is, the numbers themselves should appear as constants). If so, can the class be optimized? And will it change if something inherits from class A, but still uses only constants and does not accept their addresses?
Oh, and assuming in the version without inheritance that the class is not actually used on its own, except for access to constants.
Thank.
source
share