Path: utzoo!utgpu!attcan!uunet!lll-winken!lll-tis!helios.ee.lbl.gov!nosc!ucsd!rutgers!uwvax!oddjob!tank!nucsrl!morrison From: morrison@eecs.nwu.edu (Vance Morrison) Newsgroups: comp.lang.c++ Subject: Re: Reuseable data structures? Message-ID: <8180017@eecs.nwu.edu> Date: 2 Sep 88 18:06:24 GMT References: <4800034@m.cs.uiuc.edu> Organization: Northwestern U, Evanston IL, USA Lines: 41 Hello In general I have found the following rule to hold Reuse of the most basic data structures requires the most advanced features of a programming language. That is reuse of a specialized piece of code is easy, but reuse of a generalized 'list', 'array', 'set' is more difficult. In your example of a linked list, yes you can do what you said, but you will find that most (if not all) of the functions must be defined in the derived class. For example list.add(elem) list.setval(elem) list.getval() list.delete() with perhaps the exception of the delete function, all of these functions need to know how something about the type of 'elem' because of this they have to be in the derived class. This problem is characteristic of 'container classes', like arrays, list, sets, trees (essentially the most important data types). There is a solution to this problem, and it lies in the fact that most if not all the information the container class needs to know about its elements is compile time information. Thus with a little extra help from the compilier a generic list can ask for the compilier the infomation it needs. I am in the process of developing a simple preprocessor to C++ that will do this. At present, however, with standard C++, I do not believe there is a truely satisfactory solution to the problem of container classes. Vance Morrison Northwestern Univ