Private member access specifiers, Protected member access specifiers, Public member access specifiers in OOP C++
Private member access specifiers, Protected member access specifiers, Public member access specifiers in OOP C++
In this tutorial, we will learn about the followings;
What is member access specifier in OOP C++?
What is private access specifier in OOP C++?
What is protected access specifier in OOP C++?
What is public access specifier in OOP C++?
What are member access specifiers?
Members access specifiers are the instructions that controls the access of all members including attributes and functions.
There are 3 types of member access specifiers’
- Private
- Protected
- Public
1.Private access specifier:
Private members are only accessible inside their own class
2. Protected access specifier:
Protected members are accessible within the class and within its derived/child classes.
3. Public access specifier:
Public members are accessible within the class and also outside the class.
How are private protected and public declared within the class?
1 2 3 4 5 6 7 8 9 |
class furniture { private: int price; protected: char color; Public: char title; }; |
.