In this article

private (C++)

In this article

Syntax

private:
[member-list]
private base-class

Remarks

When preceding a list of class members, the private keyword specifies that those members are accessible only from member functions and friends of the class. This applies to all members declared up to the next access specifier or the end of the class.

When preceding the name of a base class, the private keyword specifies that the public and protected members of the base class are private members of the derived class.

Default access of members in a class is private. Default access of members in a structure or union is public.

Default access of a base class is private for classes and public for structures. Unions cannot have base classes.

/clr Specific

In CLR types, the C++ access specifier keywords (public, private, and protected) can affect the visibility of types and methods with regard to assemblies. For more information, see Member Access Control.

Note

Files compiled with /LN are not affected by this behavior. In this case, all managed classes (either public or private) will be visible.