Xref: utzoo comp.object:412 comp.lang.c++:5505 Path: utzoo!utgpu!utstat!jarvis.csri.toronto.edu!mailrus!shadooby!samsung!gem.mps.ohio-state.edu!ctrsol!lll-winken!arisia!sgi!shinobu!odin!horus!thant From: thant@horus.sgi.com (Thant Tessman) Newsgroups: comp.object,comp.lang.c++ Subject: Re: Understanding the Object-Oriented Life-Cycle Message-ID: <1403@odin.SGI.COM> Date: 13 Nov 89 17:03:19 GMT References: <20481@brunix.UUCP> <5026@internal.Apple.COM> <315@shrike.AUSTIN.LOCKHEED.COM> <654@nastar.UUCP> <44454@sgi.sgi.com> Sender: news@odin.SGI.COM Reply-To: thant@horus.sgi.com (Thant Tessman) Organization: Silicon Graphics, Inc. Lines: 32 In article <20481@brunix.UUCP>, sdm@brunix (Scott Meyers) writes: > Hmmm, what about using MI so that anything that will ever go on a list > inherits from a class "Listable" that defines the appropriate virtual > comparison operators? Then your lists would consist of pointers to objects > of type Listable. It should be type-safe because only Listable objects can > end up on lists, and all Listable objects have the necessary comparison > operators appropriately defined. No macros needed, and having a single > object on multiple lists is no problem. Am I overlooking something? > > Scott > sdm@cs.brown.edu I don't know. I think what you describe is fine for doing 'listy' type things on lists. But, in my case, what I really wanted was a list of Goobers that I could do 'goobery' things with as well as 'listy' things. In that case, I needed to overload my iterator to return the correct type. This guarantees that I can't to 'goobery' things to any old list, just to lists of Goobers. Since List was a base class of Goober (I didn't really call it Goober) all the list stuff automatically worked and was type safe. And even this won't solve the problem of allowing a list where each element can be anything. (I don't even think dynamic typing is a solution. What does the program written in a dynamic typing language do when the type is wrong that you couldn't get a c++ program to do just as easily?) thant -------------------------- There are 336 dimples on the standard golf ball.