Java and Smalltalk have single inheritance while C++ and Python support multiple inheritance. code example

Example 1: multiple inheritance in python

# Example of multiple inheritance
# I recommend to avoid it, because it's too complex to be relyed on.

class Thing(object):
    def func(self):
        print("Function ran from class Thing()")

class OtherThing(object):
    def otherfunc(self):
        print("Function ran from class OtherThing()")
      
class NewThing(Thing, OtherThing):
    pass

some_object = NewThing()

some_object.func()
some_object.otherfunc()

Example 2: how to achieve multiple inheritance in java

Multiple inheritance is achieved and
implemented using interfaces.

Tags:

Misc Example