Path: utzoo!attcan!uunet!mcvax!ukc!reading!cf-cm!tel From: tel@computing-maths.cardiff.ac.uk (Ted Lawson) Newsgroups: comp.lang.c++ Subject: Re: Reuseable data structures? Summary: Parameterised classes are supplied with Eiffel Message-ID: <534@cf-cm.UUCP> Date: 7 Sep 88 15:11:01 GMT References: <4800034@m.cs.uiuc.edu> Organization: Univ. Coll. Cardiff, Cardiff, WALES, UK. Lines: 34 In article <4800034@m.cs.uiuc.edu>, shirley@m.cs.uiuc.edu writes: > ... > I want to write code for a certain data structure, say a linked list, and > I want to use it for all classes, can C++ handle this gracefully? > I know this s not a answer to your question but... An OO language which addresses the problem directly and rather elegantly is Eiffel. In fact Eiffel comes with a library of classes which includes not just lists (of various kinds) but also stacks, trees, queues, deques and other aggregate structures. The type of the object to be stored is defined as a parameter. You can create your own type-parameterised classes or make specialised and combined versions of the library ones using single and multiple inheritance. These classes have most of the properties of other Eiffel classes so you can supply one of them as the actual type-parameter of another. It is then possible to construct interesting composites such as lists of stacks of queues of ... of integers (or whatever). I think the solution is probably neater than anything you achieve with C++. I have yet to compare Eiffel with C++ on performance though. More information... B. Meyer, "Genericity versus Inheritance ", OOPSLA '86 Proceedings, 391-405, (1986) "Eiffel: A Language and Environment for Software Engineering ", Interactive Software Engineering, Inc., Goleta, CA ...oooOOOooo... Not necessarily my employer's views. Ted Lawson