Home Forums Programming Beginning C++ Reply To: Beginning C++

#42078
Anonymous
Inactive

no that wont be a compiler error, your just re-assigning a variable.

const is a guarantee that this variable will not change if declared with const(eventhough you cannot change it even if you want to (well you can using a cast but ignore for now)). Typically you might use it for magic numbers.

const int SCREEN_WIDTH = 640;
const int SCREEN_HEIGHT = 480;

You declare like this, as the screens width and height will not change during runtime.

There are about 5 places const are used, all except this case are alot more involved for a beginner, so ignore for now. If you do want to know them all (its a standard interview question ;)) check out the site omen post earlier in this thread.