Item 2, Scott Myers Effective C++ question
- by user619818
In Item2 on page 16, (Prefer consts, enums, and inlines to #defines), Scott says:
'Also, though good compilers won't set aside storage for const objects of integer types'.
I don't understand this. If I define a const object, eg
const int myval = 5;
then surely the compiler must set aside some memory (of int size) to store the value 5?
Or is const data stored in some special way?
This is more a question of computer storage I suppose. Basically, how does the computer store const objects so that no storage is set aside?