0% found this document useful (0 votes)
36 views3 pages

Explanation: Access Specifiers Defines The Access Rights For The

Access specifiers define the visibility and accessibility of class members, with private restricting access to only the class, public allowing access from inside and outside the class, and protected permitting access from the class and derived classes. The three main access specifiers are private, public, and protected.

Uploaded by

hariomz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views3 pages

Explanation: Access Specifiers Defines The Access Rights For The

Access specifiers define the visibility and accessibility of class members, with private restricting access to only the class, public allowing access from inside and outside the class, and protected permitting access from the class and derived classes. The three main access specifiers are private, public, and protected.

Uploaded by

hariomz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Explanation

Access specifiers defines the access rights for the


statements or functions that follows it until another
access specifier or till the end of a class. The three
types of access specifiers are "private", "public",
"protected".
private:
The members declared as "private" can be accessed
only within the same class and not from outside the
class.
public:
The members declared as "public" are accessible within
the class as well as from outside the class.
protected:
The members declared as "protected" cannot be
accessed from outside the class, but can be accessed
from a derived class. This is used when inheritaance is
applied to the members of a class.











Access specifier in
C++ classes used as
access control:
Members of a class can be restricted or controlled
on its access within and outside that class. This is
achieved by declaring members in either of the 3
access specifiers:
Private access specifier:
All member of a class are restricted to be accessed
only by members of the same class and friend
function and members of friend class.
Public access specifier:
All member of a class are free to be accessed by
anyone, anywhere within and outside its class.
Protected access specifier:
All member of a class are restricted to be accessed
only by members of the same class and its direct
or indirect derived classes and friend function and
members of friend class

You might also like