All members of a structure in C++ are ____ by default.

2023

All members of a structure in C++ are ____ by default.

  1. A.

    public

  2. B.

    private

  3. C.

    protected

  4. D.

    More than one of the above

  5. 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.

Explore the full course: Up Lt Grade Assistant Teacher 2025