|
|
The public access specifier declares public members of a class. It is also used to publicly inherit a base class. When used to declare public members, it has this general form:
class class-name { // private members by default public: // make public // public members };
Members of a class are private by default. To declare public members of a class, you must specify them as public.
When used as an inheritance specifier, public has this general form:
class class-name : public base-class { // ...
By specifying a base class as public, all public members of the base class become public members of the derived class and all protected members of the base class become protected members of the derived class. In all cases, private members of the base class remain private to that base.
|
|