Inheritance

Inheritance is a way to create a new class (called a derived class) from an existing class (called a base class). The derived class inherits the data members and member functions of the base class, allowing for code reuse and modularity. To inherit from a base class, use the colon (:) and the 'public' keyword, followed by the base class name:

class DerivedClass : public BaseClass {
// additional members
};
Copy code In this example, 'DerivedClass' inherits from 'BaseClass'. Derived classes can also override or extend the functionality of the base class by providing new implementations for inherited member functions.