[go: up one dir, main page]

0% found this document useful (0 votes)
47 views11 pages

of Access Specifiers.

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

of Access Specifiers.

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

Presentation

ON
Access Specifiers
in C++

Powered by- jpwebdevelopers


Contents :
 Introduction to Access Specifiers
Types of Access Specifiers

powered by jpwebdevelopers
INTRODUCTION TO ACCESS SPECIFIERS :

Access Specifiers (modifiers) are keywords in C+


+ . Access Specifiers define how the members of a class can
be accessed. It sets some restrictions on the class members
not to get directly accessed by the outside functions.

powered by jpwebdevelopers
TYPES OF ACCESS SPECIFIERS :

In C++, there are three 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

specifier and it is similar to private , it make class member

inaccessible outside the class. But they can be accessed by any sub

class of that class.


• The protected keyword is used to create protected members (data
and function).
• The protected members can be accessed within the class and from
the derived class.

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

You might also like