In C++, all members of a class are ______ by default.
2023
In C++, all members of a class are ______ by default.
- A.
public
- B.
private
- C.
protected
- D.
More than one of the above
- E.
None of the above
Attempted by 624 students.
Show answer & explanation
Correct answer: B
In C++, when a class is defined, the default access specifier for its members (data members and member functions) is private. This means that unless explicitly specified otherwise, all members of a class are private by default. This behavior ensures encapsulation, a key principle of object-oriented programming.