...
Objects that are const
-qualified have scope and can be type-checked by the compiler. Because these are named objects (unlike macro definitions), (certain) some debugging tools can show the name of the object. The objects object also consumes memory (though this is not too important).
A const
-qualified objects allows you to specify the exact type of the constant. For example:
...
If any of these are required, then an integer constant (which would be an rvalue) must be used.
const
-qualified objects allows allow the programmer to take the address of the object.
...
Wiki Markup |
---|
{{const}}\-qualified objects are likely to incur some runtime overhead \[[Saks 01b|AA. C References#Saks 02]\]. Most C compilers, for example, allocate memory for {{const}}\-qualified objects. {{const}}\-qualified objects declared inside a function body willmay have automatic storage duration. Consequently,If ifso the compiler will allocatesallocate storage for the object, and it will be on the stack and. As a result, this storage will need to be allocated anand initialized each time the containing function is invoked. |
...