Which OOP feature allows a new C++ class to acquire properties and behaviour of an existing class?

Options

  • A. Encapsulation
  • B. Inheritance
  • C. Abstraction
  • D. More than one of the above
  • E. None of the above

Correct Answer (Detailed Explanation is Below)

B. Inheritance

Detailed Explanation

Answer: Inheritance

Inheritance allows a new class, called the derived class, to acquire properties and behaviours of an existing class, called the base class.

For example, if Car is derived from Vehicle, the Car class can inherit suitable members of Vehicle.