By default in C++, the member of a class are _____, while, by default the…

20212021

By default in C++, the member of a class are _____, while, by default the member of structure are _____.

  1. A.

    private; private

  2. B.

    public; public

  3. C.

    private; public

  4. D.

    public; private

Attempted by 176 students.

Show answer & explanation

Correct answer: C

In C++:

  • Members of a class are private by default.

  • Members of a structure (struct) are public by default.

Example:

class A {
   int x;   // private by default
};

struct B {
   int y;   // public by default
};

Therefore, the correct answer is private; public.

Explore the full course: Uppsc Polytechnic Lecturer 2025 Cs