Access specifiers in C++
Access specifiers, as the name suggests, specifies the access
boundary or scope of a data member or function. In C++, there are
three C++ keywords that act as access specifiers, these are:
a)private
b)public
c)protected
By default, the data members and
functions are private
to the class it is declared in. This means that are accessible only
by the members of the class.
The data members and member
functions declared public
,
are accessible by the objects, derived classes, friend class and
friend function.
The
data and functions declared protected
are
accessible by the class member functions and derived classes but not
by objects or friend function(s) and classes.
Access specifiers in C++ |
Thank you.
ReplyDelete