Explain the different type of access specifiers in OOPs.

: 3054
Paper : C++ Programming FAQ (Frequently Asked Questions and answers) for freshers | Platform : Object-oriented programming Language | Category : Programming FAQs

There are three types of access specifier: 

  • Private: When the class members are defined under a private specifier, then it is accessible only inside the class. The programmer is not allowed to use outside the class.
  • Public: When defined in public, then it is accessible anywhere in the complete program. The programmer can call the member from anywhere with the help of an object of the class. In simple words, you can say it is globally accessible in the program. 
  • Protected: The protected member of the parent class is accessible only in the child classes.