All members of a structure in C++ are ____ by default.
2023
All members of a structure in C++ are ____ by default.
- A.
public
- B.
private
- C.
protected
- D.
More than one of the above
- E.
None of the above
Attempted by 678 students.
Show answer & explanation
Correct answer: A
In C++, the default access specifier for members of a structure is public. This means that all members of a structure are accessible from outside the structure without any explicit access control. This behavior is different from a class in C++, where the default access specifier is private. Therefore, when defining a structure, you do not need to explicitly declare members as public; they are public by default.