of Access Specifiers.
of Access Specifiers.
ON
Access Specifiers
in C++
powered by jpwebdevelopers
INTRODUCTION TO ACCESS SPECIFIERS :
powered by jpwebdevelopers
TYPES OF ACCESS SPECIFIERS :
PUBLIC
PRIVATE
PROTECTED
powered by jpwebdevelopers
• PUBLIC ACCESS SPECIFIERS -: The Public keyword is used
to create public member.(data and function)
• The Public members are accessible from any part of program.
• It means all the class members declared under Public will be
available to everyone.
• The data members and member functions declared public can
be accessed by other classes too.
powered by jpwebdevelopers
Example of public access specifiers :
class ABC
{
public : // Public access modifiers
int x; // data member
void display(); //member function
};
powered by jpwebdevelopers
PRIVATE ACCESS SPECIFIERS:- Private keyword means
that no one can access the class members declared
private, outside the class.
If someone tries to access the private number of a class,
they will get a compile time error.
The private keyword is used to create private members
(data and function).
The private members can only be accessed from within
the class.
However, friend classes and friend functions can access
private members.
powered by jpwebdevelopers
Example of private access specifiers :
class ABC
{
private : // Private access modifiers
int x; // data member
void display(); //member function
};
powered by jpwebdevelopers
• PROTECTED ACCESS SPECIFIERS -: Protected is the last access
inaccessible outside the class. But they can be accessed by any sub
powered by jpwebdevelopers
Example of protected access specifiers :
class ABC
{
protected : // Protected access modifiers
int x; // data member
void display(); //member function
};
powered by jpwebdevelopers
Thank
YOU
Download ppt’s and handwritten notes
JP Web devolpers
Follow on instagram:-@jpwebdevelopers
powered by jpwebdevelopers