Wrapper Function - Multiple Inheritance

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:

    There is a continual exchange of ideas between all minds of a generation. Journalists, popular novelists, illustrators, and cartoonists adapt the truths discovered by the powerful intellects for the multitude. It is like a spiritual flood, like a gush that pours into multiple cascades until it forms the great moving sheet of water that stands for the mentality of a period.
    Auguste Rodin (1849–1917)

    As to honour—you know—it’s a very fine mediaeval inheritance which women never got hold of. It wasn’t theirs.
    Joseph Conrad (1857–1924)