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 _____.
- A.
private; private
- B.
public; public
- C.
private; public
- D.
public; private
Attempted by 176 students.
Show answer & explanation
Correct answer: C
In C++:
Members of a class are
privateby default.Members of a structure (
struct) arepublicby default.
Example:
class A {
int x; // private by default
};
struct B {
int y; // public by default
};Therefore, the correct answer is private; public.