LOGBOOK

HELP

Quiz Entry - updated: 2026.07.14

What are the three access specifiers in C++?

public (accessible anywhere), private (only inside the class), and protected (the class plus its derived classes).

Three access levels from most open (public) to most closed (private)

* The three levels run from fully open (public) to fully closed (private), with protected sitting in between for subclasses. *

Specifier Accessible from
public Anywhere
private Only within the class
protected Within the class and derived (sub)classes
class Example {
public:
    int a;     // anyone can access
protected:
    int b;     // this class + subclasses
private:
    int c;     // this class only
};

Default access:

  • classprivate by default
  • structpublic by default

Tip: Access control is about encapsulation — hiding internal state behind a controlled public interface so the rest of the program can't depend on (or corrupt) it.

Go deeper:

From Quiz: REVE1 / C++ Programming | Updated: Jul 14, 2026