Question about Constants

Only the values are stored. The exact storage method depends on the machine architecture and the compiler. Optimization such as re-use of identical values is compiler dependent. 8 bit constants (on a machine with an 8 bit data bus) are often embedded in the machine code, inline, using "immediate" addressing modes. Sometimes called "literal".

Constants that are too big to fit in a machine instruction are allocated a place in memory and referenced with a memory address. Whether that is in ROM or RAM is machine dependent.

By the way, the examples you show, would suit an 'enum' better than individual declarations.
https://en.cppreference.com/w/cpp/language/enum

1 Like