What is the default inheritance mode when a C++ struct derives from another type?
Options
- A. Private inheritance
- B. Protected inheritance
- C. Public inheritance
- D. More than one of the above
- E. None of the above
Quiz Practice:
C. Public inheritance
Answer: (C) Public inheritance
When a derived type is declared using the struct keyword, inheritance is public by default.
For example:
struct Base { };
struct Derived : Base { };
The above is equivalent to:
struct Derived : public Base { };
This is an important distinction between class inheritance and struct inheritance.