|Synopsis:||Avoid inheritance for parts-of relations|
|Category:||Object Oriented Programming|
A common mistake is to use multiple inheritance for parts-of relations (when an object consists of several other objects, these are inherited instead of using instance variables). This can result in strange class hierarchies and less flexible code. In C++ there may be an arbitrary number of instances of a given type; if inheritance is used, direct inheritance from a class may only be used once.
|Ellemtel Rec. 37|