Chapter     9

Controlling Data with Access Modifiers

C++ allows you to control how data in variables can be accessed by using different access modifiers. There are modifiers that tell the compiler that a variable should be shared among classes or that the program cannot change the value of the variable after it has been initialized. Unfortunately some of the keywords supplied by C++ are reused and mean different things in different circumstances. I’ll cover the use of the static, const, mutable, and friend keywords in C++, and their multiple uses in this chapter.

The static Keyword

The static keyword has four major uses in C++ programs:

  • It is used within functions to indicate that a variable should remember its value each time the function ...

Get Learn C++ for Game Development 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.