Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!linus!philabs!pwa-b!mmintl!franka From: franka@mmintl.UUCP (Frank Adams) Newsgroups: comp.lang.c++ Subject: Re: C++ libraries... Message-ID: <2443@mmintl.UUCP> Date: Wed, 30-Sep-87 20:06:52 EDT Article-I.D.: mmintl.2443 Posted: Wed Sep 30 20:06:52 1987 Date-Received: Tue, 6-Oct-87 04:05:22 EDT References: <1096@g.gp.cs.cmu.edu> Reply-To: franka@mmintl.UUCP (Frank Adams) Organization: Multimate International, E. Hartford, CT. Lines: 43 In article <1096@g.gp.cs.cmu.edu> dld@g.gp.cs.cmu.edu (David Detlefs) writes: > How do inheritance and parameterized classes interact? I think that >if a class is not originally parameterized, you probably should not be >able to introduce parameters for subclasses. This would prevent having a class Object from which all other classes are derived. I would probably want to define a parameterized hash table class as a subclass of an Array class; the Array class might be parameterized, but one would be adding new parameters (the hash function) which the superclass did not have. Given the ability to add new parameters, there seems no reason to forbid adding parameters to unparameterized classes. >Can one derive a class directly from a parameterized class, getting a >parameterized subclass? I would think so. ------------------------- One question needs to be asked here. How are the parameters of the class any different from the instance variables of the class? It seems like the real problem here is that many of the things one wishes to parameterize over are not first-class objects. Instead of a class array[element_type, size], parameterized by the type and number of objects stored in the array, one would like to have a definition like the following: class array { type element_type; int size; element_type contents[size]; ... } There are a lot of problems with implementing something like this, of course. But then, parameterized classes are not trivial, either. (One might wish to require that element_type and size be declared const in the above example, meaning that they can only be set upon initialization.) -- Frank Adams ihnp4!philabs!pwa-b!mmintl!franka Ashton-Tate 52 Oakland Ave North E. Hartford, CT 06108