Access modifiers or Access specifiers are keywords in object oriented language that set the accessibility of classes,methods and other members.
There are 3 types of access modifiers available in C++:
Public: There are no restrictions on accessing public members. The public members of a class can be accessed from anywhere in the program using the direct member access operator (.) with the object of that class.
Private: Access is limited to within the class definition. This is the default access modifier type if none is formally specified. They are not allowed to be accessed directly by any object or function outside the class.
Protected: Access is limited to within the class definition and any class that inherits from the class.
Why do we use access modifiers in c++????????
Access modifiers are an integral part of object-oriented programming. They are used to implement the encapsulation of OOP. The access modifiers allow you to define who does or who doesn’t have access to certain features.