O'Reilly logo

SAMS Teach Yourself C++ in 10 Minutes SECOND EDITION by Jesse Liberty

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required