Path: utzoo!utgpu!attcan!uunet!lll-winken!lll-tis!ames!mailrus!tut.cis.ohio-state.edu!rutgers!rochester!pt.cs.cmu.edu!f.gp.cs.cmu.edu!dld From: dld@f.gp.cs.cmu.edu (David Detlefs) Newsgroups: comp.lang.c++ Subject: Re: Reuseable data structures? Summary: Use paramterized types. Message-ID: <2866@pt.cs.cmu.edu> Date: 2 Sep 88 17:07:07 GMT References: <4800034@m.cs.uiuc.edu> Sender: netnews@pt.cs.cmu.edu Organization: Carnegie-Mellon University, CS/RI Lines: 19 I believe that the best thing to do is to use the C preprocessor to get the effect of paramterized classes, as on page 210 of Stroustrup's book. I'm working on a library of such classes. I think that people sometimes are a little overzealous in trying to make inheritance the answer to all program structuring problems -- the kind of of problem you pose is most simply solved as a parameterized class. (Why require that the list elements be subclasses of "thing"? When you write "list", you want to be able to make lists of anything. When you write a class "foo," you definitely don't want to worry then about whether it should inherit from "linked_list_elem", "tree_elem", "sortable_elem", "hashable", etc. You simply want the compiler to ensure that those things that you do use as parameters to parameterized types have the proper signatures. -- Dave Detlefs Any correlation between my employer's opinion Carnegie-Mellon CS and my own is statistical rather than causal, dld@cs.cmu.edu except in those cases where I have helped to form my employer's opinion. (Null disclaimer.)