Private protected and public access specifier in c++ OOP

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’

  1. Private
  2. Protected
  3. 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 withing the class and also outside the class.

How private protected and public are declared within class?

Serial# Code
1 class furniture
2 {
3 private:
4 int price;
5 protected:
6 char color;
7 Public:
8 char title;
9 };