What does "Multiple Inheritance" Mean?

Article Details
  • Written By: Vanessa Harvey
  • Edited By: A. Joseph
  • Last Modified Date: 04 November 2019
  • Copyright Protected:
    Conjecture Corporation
  • Print this Article
Free Widgets for your Site/Blog
People with auto-brewery syndrome convert carbs into ethanol in their gut, becoming drunk without drinking alcohol.  more...

November 13 ,  1956 :  The US Supreme Court upheld a decision that ended public bus segregation in Montgomery, Alabama.  more...

Multiple inheritance, when speaking of object-oriented programming (OOP) languages, is a term that refers to a class that inherits functionality from more than one parent class. The term cannot be fully grasped without understanding what a class is. A very brief definition of a class is a set of programming instructions or code in an OOP language that describes and is the essence of an entity. Classes define all of the properties of an entity and contain all of the methods necessary for manipulating those properties.

Depending on the program that is being coded, there might be a need to write many classes that have things in common but need to remain distinct entities. This is where multiple inheritance comes into play. For example, technological advances that would allow the building of a submarine that could fly like an airplane or an airplane that could submerge like a submarine would produce a hybrid product. That hybrid would have some of the same properties as an airplane has and some of the properties of a submarine, but it would be a unique product or entity. Multiple inheritance would easily allow the hybrid to inherit functionality from an airplane class and functionality from a submarine class at the same time without copying code.


Another way of explaining multiple inheritance is to say that it allows more than one class to act as the base for other classes. There are advantages to using multiple inheritance instead of simply copying code from one or more classes to another. Bugs in programs often take time to be discovered, but when they are discovered, they need to be corrected as soon as possible. If code containing bugs is copied to several classes, programmers must apply the same fix to every copy of the code. When multiple inheritance is employed, however, he or she would have to work with the code of only the original class from which all of the subclasses inherit functionality.

Not all programming languages support multiple inheritance, even if they support object orientation. Some versions of some languages might be claimed to support it when in reality they support inheritance from only two classes. The classes from which other classes inherit functionality are often referred to as "parent" classes or "super classes," and the classes that inherit are called "child" classes or "subclasses." Programmers who are interested in working with classes in this way are strongly advised to first gain a solid knowledge of the basics of classes before attempting to take advantage of the power of multiple inheritance, because mistakes or poor coding practices in the parent class are passed down to the child class.


You might also Like


Discuss this Article

Post your comments

Post Anonymously


forgot password?