Path: utzoo!mnetor!uunet!husc6!cmcl2!nrl-cmf!ames!ptsfa!well!mitsu From: mitsu@well.UUCP (Mitsuharu Hadeishi) Newsgroups: comp.lang.c++ Subject: Re: generic types Message-ID: <5028@well.UUCP> Date: 18 Jan 88 19:19:39 GMT References: <217@goofy.megatest.UUCP> Reply-To: mitsu@well.UUCP (Mitsuharu Hadeishi) Organization: Whole Earth 'Lectronic Link, Sausalito, CA Lines: 34 Keywords: generic types class derived Summary: The Book is woefully incomplete here We've developed a set of macros for deriving from generic classes that allows full flexibility (and even a kind of multiple inheritance) without causing the implementor to have to define a whole bunch of macros. The implementor simply defines the "body" of the class as a macro, with possible parameters a type or two and a class name. If the programmer wishes to avoid having to specify a class name, s/he can use the simplest macro "Declare()" (similar to the "declare()" macro in The Book.) Declare(), however, is defined in terms of a series of ever-more precise macros which allow the programmer increasing flexibility. The "body" macro is NOT a full class declaration, only the "body" of the class (the member functions). If the programmer wishes to create his/her own class derived from the base class (say, "ListElement") s/he can simply say class NameNode : public ListElement { char name[40]; public: // ... Inherit(ListElement,NameNode); }; This is appropriate for those generic classes that almost always require the addition of data members to be useful (a linked list without any data is pretty useless.) We've spent a long time arguing over the names, and have come up with a fairly simple, standard convention. Of course, all of this will be rendered unnecessary when and if parameterized classes are introduced into C++; however, we find it useful for our current needs. -Mitsu Hadeishi Electronic Arts