Inheritance allows objects of one class to inherit properties from another class. There are different types of inheritance including single, multilevel, hierarchical and multiple inheritance. Inheritance is achieved by defining a derived class that inherits from a base class using the class derived-class-name : visibility-mode base-class-name syntax. This allows code reuse and makes classes extensible for further use in derived classes. The example shows different classes like Student, Test and Sports with inheritance and a Result class derived from Test and Sports to demonstrate inheritance.