| Prev | Next | Start of Chapter | End of Chapter | Contents | Glossary | Index | Comments | (15 out of 18)

Duplicate Attributes in Multiple Inheritance

Where multiple inheritance exists, a subclass can inherit user-defined attributes with the same name from more than one superior class. Such duplication does not arise when a subclass inherits the same attribute through more than one path. It occurs only when different attributes with the same name exist in different ancestral classes.

G2 handles duplicate attributes that arise from multiple inheritance just as it does those arising from single inheritance: it follows the class inheritance path, uses the first definition it encounters without qualification, and qualifies any others with the relevant class name.

For example, consider again the PC-NET multiple inheritance structure:


Suppose that, as indicated in the figure:

PC-NET's class inheritance path is:

The following figure shows the definition table for PC-NET, along with the table of pc-netw-1, an instance of PC-NET.


Note that the Capital-expense attribute appears only once, even though PC-NET inherits it from two different sources: PC and NETWORK. Both of these definitions are really the same definition, inherited from EQUIPMENT, so G2 defines only one Capital-expense attribute in PC-NET. G2 qualifies the other inherited attributes as needed by following the class inheritance path, as described above.

If PC-NET's direct superior classes were NETWORK and PC, in that order, giving PC-NET the class inheritance path:

the attributes of a PC-NET would be:

| Prev | Next | Start of Chapter | End of Chapter | Contents | Glossary | Index | Comments | (15 out of 18)

Copyright © 1997 Gensym Corporation, Inc.