August 2002
Beginner
1122 pages
22h 1m
English
This is another of the places where it's important to differentiate between initialization and assignment. We can't assign a value to a const, but we can initialize it; in fact, because an uninitialized const is useless, the attempt to define a const without specifying its initial (and only) value is a compile-time error. In this case, we're initializing it to the value 256; if we just wrote const short BUFLEN;, we'd get an error report something like the one in Figure 8.35 when we tried to compile it.
STRING5X.cpp: Error E2304 STRING5X.cpp 82: Constant variable 'BUFLEN' must be initialized in function operator >>(_STL::istream &,string &) Error ... |
Read now
Unlock full access