Name
public access specifier — No restrictions on member access
Synopsis
access-specifier := public
The public
keyword can be
used within a class definition (followed by a colon) to mark
subsequent member declarations as public or before a base-class name
in the class header to mark the inheritance as public. The default
access level of a struct
is public,
both for members and base classes.
Public members can be used freely by any other class or function.
Public inheritance means all members of the base class retain their accessibility levels.
See private
for an
example.
See Also
class
, private
, protected
, struct
, Chapter 6
Get C++ In a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.