previous up next print clean
Next: SUMMARY AND CONCLUSIONS Up: C++ DIFFICULTIES Previous: Garbage collection

Multiple Inheritance

Were HCL to follow strictly mathematical relationships, some of HCL's abstract base classes would need to be derived simultaneously from several parent classes. However, multiple inheritance can pose serious compiler problems, especially when the parent classes have common ancestors themselves.

 
multinh
Figure 1
Multiple inheritance is mathematically desirable, but difficult to implement in C++.

multinh

For example, in Figure 1 a compound linear operator with adjoint should be derived from the compound linear operator and from the linear operator with adjoint. Both parent classes are derived from the linear operator. However, the compound linear operator with adjoint would inherit all linear operator members twice; a fact some compilers do not seem to appreciate.

In general, C++ practitioners advise against such multiple inheritance and HCL avoids them entirely. When does multiple inheritance matter? If we had a solver that inverts linear operators with adjoints and another one that inverts compound linear operators, a compound linear operator with adjoint should be an acceptable argument to both solvers. However, without multiple inheritance, the operator will be acceptable to only one of the solvers.


previous up next print clean
Next: SUMMARY AND CONCLUSIONS Up: C++ DIFFICULTIES Previous: Garbage collection
Stanford Exploration Project
11/11/1997