Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!pdn!tscs!tct!chip From: chip@tct.com (Chip Salzenberg) Newsgroups: comp.lang.c++ Subject: Re: How to define a List class Message-ID: <28539115.4D91@tct.com> Date: 10 Jun 91 14:47:49 GMT References: <350001@hpgnd.grenoble.hp.com> Organization: Teltronics/TCT, Sarasota, FL Lines: 23 According to jr@hpgnd.grenoble.hp.com (Jean-Ren BOUVIER): >I'm looking for ideas in the classical area of "list" packages. ... > >I DON'T want to consider solutions based on templates (List >types) or generic classes - as I don't want to replicate code. Well, then, you've got very few alternatives. In C++, you cannot have all three of minimal-code polymorphism, type safety and involiate base classes. That is because the three approaches to the downcasting problem fall short in one way or another: 1. Templates (sometimes implemented with the preprocessor) almost always result in some duplicate code. 2. Brute-force downcasting completely trashes type safety. 3. Virtual downcast functions require modifying the base class for each new derivation. There is no magic bullet. Choose your poison and make it work. -- Chip Salzenberg at Teltronics/TCT , perl -e 'sub do { print "extinct!\n"; } do do()'