Multiple Inheritance
In a programming language that does not support multiple inheritance of base classes, wrapper functions can be used to simulate it. Below is an example of part of a Java class that "inherits" from LinkedList and HashSet.
public class StackSet implements Stack, Set { private LinkedList stack; private HashSet set; public boolean push(Object o) { if (set.add(o)) return stack.push(o); else return false; } public Object pop { Object o = stack.pop; set.remove(o); return o; } public boolean contains(Object o) { return set.contains(o); } }Read more about this topic: Wrapper Function
Famous quotes containing the words multiple and/or inheritance:
“... the generation of the 20s was truly secular in that it still knew its theology and its varieties of religious experience. We are post-secular, inventing new faiths, without any sense of organizing truths. The truths we accept are so multiple that honesty becomes little more than a strategy by which you manage your tendencies toward duplicity.”
—Ann Douglas (b. 1942)
“A child is born with the potential ability to learn Chinese or Swahili, play a kazoo, climb a tree, make a strudel or a birdhouse, take pleasure in finding the coordinates of a star. Genetic inheritance determines a childs abilities and weaknesses. But those who raise a child call forth from that matrix the traits and talents they consider important.”
—Emilie Buchwald (20th century)