Access Modifiers in C++

Level : Advanced
Mentor: Shailendra Chauhan
Duration : 00:01:00

What are access specifiers in C++?

Access specifiers specify how the members of a class (data members and member functions) can be accessed. They enable us to determine which class members are visible to other classes and functions and which are not.

Different types of access modifiers in C++

C++ includes three access specifiers:

  1. Public 
  2. Private 
  3. Protected

Public

Members who have been declared as public can be accessed from anywhere in the program, both inside and outside of class.

Private

Members marked as private can only be accessed from within the same class, rendering them not accessible from outside.

Protected

Members selected as protected are available inside the same class and by derived classes, but not from other classes.


Self-paced Membership
  • 24+ Video Courses
  • 825+ Hands-On Labs
  • 400+ Quick Notes
  • 125+ Skill Tests
  • 10+ Interview Q&A Courses
  • 10+ Real-world Projects
  • Career Coaching Sessions
  • Email Support
Upto 60% OFF
Know More
Still have some questions? Let's discuss.
CONTACT US
Accept cookies & close this