Multiple choice

The members (variables and methods) of a class are by default specified as _________

  1. private

  2. public

  3. protected

  4. friend

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

A class has two types of members- variables and methods. To specify the accessibility of a class member, we can use access specifiers. There are three types of access specifiers available in C++ - private, public and protected. If none of the these is specified, the members have by default 'private' accessibility. A private member can be accessed inside the class but cannot be accessed using a class object. A private member cannot be inherited by a derived class also.