Inheritance is a language feature.
In object-oriented programming, inheritance is the mechanism of basing an object or class upon another object (prototype-based inheritance) or class (class-based inheritance), retaining similar implementation.
Languages with Inheritance include Java, JavaScript, Python, PHP, Scala, TypeScript, Dart, Groovy, CoffeeScript, Pug, SystemVerilog, Twig, Apex
class B {}
class A extends B {}
class SumComputer(object):
def __init__(self, a, b):
self.a = a
self.b = b
def transform(self, x):
raise NotImplementedError
def inputs(self):
return range(self.a, self.b)
def compute(self):
return sum(self.transform(value) for value in self.inputs())
class SquareSumComputer(SumComputer):
def transform(self, x):
return x * x
class CubeSumComputer(SumComputer):
def transform(self, x):
return x * x * x