access-specifier : member-specificationAn access-specifier specifies the access rules for members following it until the end of the class or until another access-specifier is encountered.
class X { int a; // X::a is private by default: class used public: int b; // X::b is public int c; // X::c is public };
struct S { int a; // S::a is public by default: struct used protected: int b; // S::b is protected private: int c; // S::c is private public: int d; // S::d is public };
struct S { class A; enum E : int; private: class A { }; // error: cannot change access enum E: int { e0 }; // error: cannot change access };
class A { }; class B : private A { }; class C : public B { A* p; // error: injected-class-name A is inaccessible ::A* q; // OK };