Which of the following access specifiers is used in a class definition by default ?

A. Protected

B. Public

C. Private

D. Friend

Answer : C. Private

Explanation :

  • Public – The members declared as Public are accessible from outside the Class through an object of the class.
  • Protected – The members declared as Protected are accessible from outside the class but only in a class derived from it.
  • Private – These members are only accessible from within the class. No outside Access is allowed.
  • Friend – A friend function of a class is defined outside that class scope but it has the right to access all private and protected members of the class.

Categorized in:

Tagged in:

, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,