aaron@rruxh.UUCP (Akman) (06/06/90)
I'm reading the Dewhurst, Stark text on C++, and I have a question re Genericity: I gather, from pp. 88-91, that using generic.h macros to fake genericity is a standard way of doing business? That doesn't seem too pleasant to me...for the example discussed it would also be possible to have a common base class for all things that you'd like to be able to have collections of, and virtual base functions (I might be misusing the terms) could be redefined in each of the classes. Like this: THING is an object, String is a THING and Complex is a THING. Then declare a collection of THINGs and insert Strings into it, or insert Complexes into it (as the case may be). This method seems less annoying to me and you could keep lots of common things in THING; the disadvantabe I see is that you couldn't have "regular" types like char, int, double have THING as a base class, so you'd have to invent myint, mydouble, etc. Any thoughts from someone who has done this a bit? -- ----------- Aaron Akman, 201-699-8019, bellcore!rruxh!aaron, RRC 4D-728
steve@taumet.com (Stephen Clamage) (06/06/90)
In article <AARON.90Jun5132030@rruxh.rruxh.UUCP> aaron@rruxh.UUCP (Akman) writes: >I'm reading the Dewhurst, Stark text on C++, and I have a question >re Genericity: I gather, from pp. 88-91, that using generic.h >macros to fake genericity is a standard way of doing business? ... Well, <generic.h> comes with the AT&T release of C++ version 2.0 and 2.1. It is not part of the *language* (as defined by the reference manual). So "standard" is probably not the correct term to use here. It is actually a stop-gap until templates (generic types) are part of the C++ language, at which time <generic.h> will be obsolete. But don't dump those files yet, folks, it may be a while before we have templates. -- Steve Clamage, TauMetric Corp, steve@taumet.com