PLDB
Languages Features Calendar About Lists Add Language
GitHub icon

Inheritance

Inheritance

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

Example from JavaScript, TypeScript:

class B {} class A extends B {}

Example from Python:

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

Article source

PLDB - Build the next great programming language. v5.0.0 - Acknowledgements · Email · GitHub