2.4. Properties
Often the internal representation of a class is modified after its initial release to users. For example, in this first version of WordCount, m_trace is declared as a bool data member; that is, it is able to be set either to true or to false. For large text files, however, users have found the generated trace text overwhelming—at least when generated to the console. They have requested that we allow them to specify whether to direct the trace to the console or to a file. Supporting this flexibility requires a change to the type representation of m_trace. It must now be able to represent three states: traceOff, toConsole, and toFile.
If m_trace is declared as public, users are free to access it directly within their code. The result ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access