[class.access.spec]

# 11 Classes [[class]](./#class)

## 11.8 Member access control [[class.access]](class.access#spec)

### 11.8.2 Access specifiers [class.access.spec]

[1](#1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/classes.tex#L4524)

Member declarations can be labeled by an[*access-specifier*](class.derived.general#nt:access-specifier "11.7.1 General [class.derived.general]") ([[class.derived]](class.derived "11.7 Derived classes")):

[*access-specifier*](class.derived.general#nt:access-specifier "11.7.1 General [class.derived.general]") : [*member-specification*](class.mem.general#nt:member-specification "11.4.1 General [class.mem.general]")opt

An[*access-specifier*](class.derived.general#nt:access-specifier "11.7.1 General [class.derived.general]") specifies the access rules for members following it
until the end of the class or until another[*access-specifier*](class.derived.general#nt:access-specifier "11.7.1 General [class.derived.general]") is encountered[.](#1.sentence-2)

[*Example [1](#example-1)*: class X {int a; // X​::​a is private by default: class usedpublic:int b; // X​::​b is publicint c; // X​::​c is public}; â *end example*]

[2](#2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/classes.tex#L4549)

Any number of access specifiers is allowed and no particular order is required[.](#2.sentence-1)

[*Example [2](#example-2)*: struct S {int a; // S​::​a is public by default: struct usedprotected:int b; // S​::​b is protectedprivate:int c; // S​::​c is privatepublic:int d; // S​::​d is public}; â *end example*]

[3](#3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/classes.tex#L4565)

When a member is redeclared within its class definition,
the access specified at its redeclaration shall
be the same as at its initial declaration[.](#3.sentence-1)

[*Example [3](#example-3)*: struct S {class A; enum E : int;private:class A { }; // error: cannot change accessenum E: int { e0 }; // error: cannot change access}; â *end example*]

[4](#4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/classes.tex#L4581)

[*Note [1](#note-1)*:

In a derived class, the lookup of a base class name will find the
injected-class-name instead of the name of the base class in the scope
in which it was declared[.](#4.sentence-1)

The injected-class-name might be less accessible
than the name of the base class in the scope in which it was declared[.](#4.sentence-2)

â *end note*]

[*Example [4](#example-4)*: class A { };class B : private A { };class C : public B { A* p; // error: injected-class-name A is inaccessible::A* q; // OK}; â *end example*]
