I need to call to say that I feel that the consensus answers that have already been given are not complete.
Given the possibility of summarizing these answers, the consensus is that we should consider the following code so as NOT to be a variable declaration, but rather a kind of macro declaration, where the compiler builds the const value wherever the identifier is used:
const int foo = 42;
However, this answer wraps up the questions that arise if a constant "variable" is declared using a (possibly complex) expression of constants, for example:
const double H = 1.23e-2, Q = 7.65e-4, nu = 0.3; const double Reynolds = H*H*H*H / Q / (1d - nu);
In this case, it matters whether the compiler evaluates the expression once and "saves" the result for reuse (for example, a static variable) or executes the expression every time an identifier is used (for example, macroC # define in C / C ++).
In my own trick, I found the following description at http://www.techopedia.com/definition/3768/constant-c that talks about this problem:
In the context of C #, a constant is a type of field or local variable whose value is set at compile time and can never be changed at run time. It looks like a variable, having a name, value and memory location. However, it differs from a variable in its characteristic for initialization only once in the application. A constant is declared using the keyword "const".
Admittedly, the "memory location" part is a kind of stretch - I believe that the value of const is stored somewhere locally during compilation. As mentioned elsewhere, you can never access or reference this memory in your code. Otherwise, it looks like what I read in the C # language specification:
8.5.2 Local constant declarations
A local declaration constant declares one or more local constants.
local standing declaration:
const type {constant declarators,} constant declarator
constant descriptor:
identifier = expression constant
and
7.19 Constant Expressions
A constant expression is an expression that can be fully evaluated at compile time.
constant expression:
Expression
...
Whenever an expression fulfills the above requirements, the expression is evaluated at compile time. This is true even if the expression is a subexpression of a larger expression containing inconsistent constructs.
Any feedback on this "quanser" is welcome: ^)