Different access specifiers for the class member in C++

Different access specifiers for the class member in C++.

Access specifiers in C++ determines the scope of the class members.
Public :
If a class member is public, it can be used anywhere without the access restrictions.
Private :
If a class member is private, it can be used only by the members and friends of class.
Protected :
If a class member is protected, it can be used only by the members and friends of class and the members and friends of classes derived from class.

Different access specifiers for the class member in C++.

Private :
It is default one and can be access from class member of the same class.
Protected :
The protected members can be access from member functions of the same class or friend classes or from the members of their immediate derived class.
Public :
The public members can be access from anywhere the class is visible.
What is the importance of mutable keyword? - C++
What is the importance of mutable keyword? - The mutable keyword allows the data member of a class to change...
Pointer vs. reference - C++
Pointer vs. reference - A reference must be initialized at the time of declaration whereas not needed...
Explain how to call C functions from C++
Explain how to call C functions from C++ - The extern keyword is used to call C functions from C++...
Post your comment