The first consideration is a very typical relationship, that is, the relationship between the rectangle and the square:
1 classrecantagle{2 Virtual voidSetHeight (int);3 Virtual voidSetWidth (int);4 Virtual intHeightint)Const;5 Virtual intWidthint)Const;6 ...7 };8 voidMakebigger (Recantagle &R)9 {Ten intOldHeight =height (); One setwidgth (WID); AASSERT (height () = =oldheight); -}
The above makebigger mainly to ensure that the process height in the Makebigger, will not be changed. But in the inheritance system, when a square width changes, the height will also be changed, so the above inheritance is actually unreasonable. So in some ways, the usual in our eyes may be rightfully sensible in fact in the inheritance system does not necessarily be able to achieve. The main problem here is that not a rectangle has properties that exist for a square, so what we call a square is a rectangle that is actually just an is-a relationship in English rather than a is-a relationship in the actual inheritance system. Summary: "Public" inheritance means is-a relationship, based on everything on Base-class should be set up on the Derived-class
Clause 32: Determine that is-a relationships are molded in public inheritance and not other relationships