Question:

What do you mean by C++ access specifiers ?

Answer:

[Questions regarding access specifiers are common not just in c++ interview but for other object oriented language interviews as well.]

Access specifiers are used to define how the members (functions and variables) can be accessed outside the class. There are three access specifiers defined which are public, private, and protected

  • private:
    Members declared as private are accessible only with in the same class and they cannot be accessed outside the class they are declared.
  • public:
    Members declared as public are accessible from any where.
  • protected:
    Members declared as protected can not be accessed from outside the class except a child class. This access specifier has significance in the context of inheritance.

Keywords:

© 2017 QuizBucket.org