C++ ClassesLesson 35Free preview
C++ Access Specifiers
This lesson is part of C++ · All levels
Summary
Access specifiers set how far a class member can be accessed from another part of the program. C++ has three specifications: public, private, and protected. In a class, members that are not given any specifier are private, while in a struct they are public.
Key points
- Private makes data accessible only from within a class or friend.
- Protected open to derivative classes remains closed to external code.
- The class is private by default, the struct is public by default.
- The specifier group is usually written at the beginning of the class and given explanatory commentary.
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.