C++ Public Access Specifiers

C++ Public Access Specifiers


C++ Public Access Specifier:

The Public is to allow the user to access a class member within the class as well as outside the class.

Any member of the class declared public access from anywhere in the program.

The member's functions are normally declared with public Access Specifier.

It is because the users access functions of objects from outside the class.

The class cannot be used directly if both data members and member functions are declared as private.

Example

Output