September 1998
Intermediate to advanced
848 pages
20h 13m
English
Use the following keywords to qualify variables:
const, volatile
A qualifier constrains a variable's ability to be modified. A const variable, after it's initialized, can't be altered. The compiler can't assume that a volatile variable hasn't been changed by some outside agency, such as a hardware update.
Note
The declaration
const int joy = 101;
establishes that the value of joy is fixed at 101.
The declaration
volatile unsigned int incoming;
establishes that the value of incoming might change between one occurrence of incoming in a program and its next occurrence.
The declaration
const int * ptr = &joy;
establishes that the pointer ptr can't be used to alter the value of the variable ...
Read now
Unlock full access