Internal State

The internal state of aRequest is represented by myOperator and myOperand. The functions on lines 17–35 of the implementation allow other classes or code to get those values.

If you refer back to Figure 18.2 in Lesson 18, “Refactoring the Calculator with Classes,” you will see that not all classes have internal state. For instance, anExternalInterface has no member variables at all.

Instances of classes such as aRequest have a single internal state for their entire life span, because their member variables cannot be changed.

Instances of classes such as anAccumulator have an internal state that changes frequently. Every call to Apply() changes the internal state of anAccumulator.

Instances of classes such as aController have an ...

Get SAMS Teach Yourself C++ in 10 Minutes SECOND EDITION now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.