Home | | Computer Science 11th std | C++: Class Access Specifiers

Chapter: 11th Computer Science : Chapter 14 : Classes and objects

C++: Class Access Specifiers

Data hiding is one of the important features of Object Oriented Programming which allows preventing the functions of a program to access directly the internal representation of a class type.

Class Access Specifiers

 

Data hiding is one of the important features of Object Oriented Programming which allows preventing the functions of a program to access directly the internal representation of a class type. The access restriction to the class members is specified by public, private, and protected sections within the class body. The keywords public, private, and protected are called access specifiers. The default access specifier for members is private.

 

The Public Members

in child classes which are called derived classes

A public member is accessible from anywhere outside the class but within a program.You can set and get the value of public data members even without using any member function.


The Private Members

A private member cannot be accessed from outside the class. Only the class member functions can access private members.By default all the members of a class would be private.

 

The Protected Members

A protected member is very similar to a private member but it Provides one additional benefit that they can be accessed (inherited classes).

Example


 


Study Material, Lecturing Notes, Assignment, Reference, Wiki description explanation, brief detail
11th Computer Science : Chapter 14 : Classes and objects : C++: Class Access Specifiers |

Related Topics

11th Computer Science : Chapter 14 : Classes and objects


Privacy Policy, Terms and Conditions, DMCA Policy and Compliant

Copyright © 2018-2024 BrainKart.com; All Rights Reserved. Developed by Therithal info, Chennai.