Category: 

What does "Multiple Inheritance" Mean?

Article Details
  • Written By: Vanessa Harvey
  • Edited By: A. Joseph
  • Last Modified Date: 14 September 2016
  • Copyright Protected:
    2003-2016
    Conjecture Corporation
  • Print this Article
Free Widgets for your Site/Blog
The U.S. Coast Guard led the evacuation of more than 500,000 people from Lower Manhattan on 11 September 2001.  more...

September 27 ,  1940 :  The World War II Axis powers formed with the signing of the Tripartite Pact.  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.

Ad

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.

Ad

You might also Like

Recommended

Discuss this Article

Post your comments

Post Anonymously

Login

username
password
forgot password?

Register

username
password
confirm
email