Xref: utzoo comp.lang.c++:6441 comp.object:926 Path: utzoo!utgpu!watserv1!watmath!att!dptg!ulysses!andante!alice!ark From: ark@alice.UUCP (Andrew Koenig) Newsgroups: comp.lang.c++,comp.object Subject: Re: Inheritance vs. Composition Message-ID: <10471@alice.UUCP> Date: 12 Feb 90 23:50:56 GMT References: <10465@alice.UUCP> Organization: AT&T Bell Laboratories, Liberty Corner NJ Lines: 25 In article , cimshop!davidm@uunet.UU.NET (David S. Masterson) writes: > In article <10465@alice.UUCP> ark@alice.UUCP (Andrew Koenig) writes: > The key difference in C++ is that if class D inherits [publicly] from > class B, then you can pass a D argument to any function that takes > a B parameter. Another way of looking at it is that if you derive > D from B, then a D object does [at least] everything a B object does. > This is interesting... > The tone here suggests that one idea is good and the other is not so good > (intentional?). Also, except for "derive...[when] object does everything [the > base] object does", there's no real suggestion of a model to follow here. I do not intend to imply that one alternative is good and the other bad -- I'm just trying to point out the differences. Each approach has its place. It's a little like trying to decide whether to use screws or nails -- each can sometimes substitute for the other, but each has advantages and disadvantages. Which one you choose depends on the details of the problem you're trying to solve. -- --Andrew Koenig ark@europa.att.com