Chapter 18. Access Control

FAQ 18.01 What is the purpose of this chapter?

This chapter presents the three types of access control in C++ classes. Access controls allow the programmer to declare a class's members as public:, protected:, and/or private:.

FAQ 18.02 How are private:, protected:, and public: different?

The situation is similar to personal secrets (shared only with friends), family secrets (shared with friends and children), and nonsecrets (shared with anybody), respectively.

A private: member of a class is accessible only by members and friends of the class.

A protected: member of a class is accessible by members and friends of the class and by members and friends of derived classes, provided they access the base member via a ...

Get C++ FAQs, 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.