Which is correct syntax of inheritance in C++?

Asked In: BPSC TRE 1.0

Options

  • A. class Base : access Derived { };
  • B. class Derived : public Base { };
  • C. class Derived : Base { };
  • D. More than one of the above
  • E. None of the above

Correct Answer (Detailed Explanation is Below)

D. More than one of the above

Detailed Explanation

Correct Answer: Option D

Explanation:
Both B and C are valid C++ syntax. In B, public explicitly specifies public inheritance. In C, the access mode is omitted, so a class uses private inheritance by default. Option A reverses the base and derived class roles.