The Private and Public Members of aRequest

You can see that the declaration of myOperator and myOperand is in the private section of the class declaration (line 44 starts that section). Because they are in the private section, these variables cannot be changed by anything except member functions of the class.

Because the constructor sets these variables, and the only member functions that deal with them do nothing but return their values, they cannot be changed once the object is instantiated.

Member variables should usually be private. The class can then selectively expose the current content (provide getter functions only), allow the current content to be changed but not reveal the current value (provide setter functions only), or allow both ...

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.