Path: utzoo!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!uunet!mcsun!unido!orthogo!basti From: basti@orthogo.UUCP (Sebastian Wangnick) Newsgroups: comp.lang.c++ Subject: Re: What to do about generics and polymorphism in C++ Message-ID: <367@orthogo.UUCP> Date: 23 Mar 90 08:12:54 GMT References: <16808@well.sf.ca.us> Organization: none Lines: 30 nagle@well.sf.ca.us (John Nagle) writes: > Let's start a discussion about the problem of how to achieve >generic objects (ones with types as parameters, at least at compile >time) in C++. What about the following possibility: Encapsulate the constaints put onto the parameter type by the generic type into a new class, and inherit a new parameter class from this one and from the original parameter class. This seems to be the way choosen in Smalltalk, where the most obvious constraints put onto objects by, let say, Collections or Sets, i.e., test for equality and generation of a hash code per object, are inherited by every object from the base class Object. Other classes putting additional burdens onto their parameter classes, such as linked lists, describe these constraints in another class, Link in this case, from which every possible parameter class has to be inherited. But with the dawn of multiple inheritance, it will be possible to use parameter classes for certain generic classes *without* recoding them, just by inheriting a new class from the original parameter class *and* the constraint class, as I stated above. This has even further benefits, because the constraint class is the source of information where all the requirements needed by the generic class from their parameter classes are bundled. Viewed with the eyes of a software engineer, this special class shouuld better be called the requirements class for the generic class. Sebastian Wangnick, BRD -> D -|||> Deutsches Reich