Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!usc!apple!landon From: landon@Apple.COM (Landon Dyer) Newsgroups: comp.lang.c++ Subject: Pure virtual functions considered broken Message-ID: <36904@apple.Apple.COM> Date: 30 Nov 89 23:55:24 GMT Organization: Apple Computer Inc., Cupertino, CA Lines: 77 Nano-summary: Pure virtual functions suffer from an apparently arbitrary language design decision. Simplified, I have a three-layer class hierarchy, something like this: TBasicBehaviour -- abstract base, common behaviour for all objects / TMumble -- a more specific abstract base / TRealMumble -- a class that actually gets instantiated TBasicBehaviour has a number of pure virtual functions. Derived from this class are additional abstract bases that add more behaviour, and derived from THOSE are the classes of which instances are actually made. In CFront it's necessary to (re-)declare a pure virtual function of a parent class, even if the subclass itself is abstract. [C++ Reference Manual, section 10.3, p68 in my copy.] The problem is that if you have MANY derived abstract bases (and why not?), this requirement can become painful to maintain. Furthermore, the requirement appears to be completely arbitrary -- a warning, rather than a hard error would be sufficient for "mothering" purposes. So there are a number of possibilities: o It's impossible to lift the restriction for obscure reasons; o It's another CFront 2.0 bug; o This is the way "it turned out"; o It really is a feature; o I'm completely mistaken and deserve enlightenment ["Oww!"]. I'm willing to listen to arguments about how CFront is doing the right thing, or about how the current behaviour is merely part of CFront's implementation, and will be fixed someday. It WOULD be nice to see a rationale ... ---------------- Here's an example, which you can skip if you like. (You'll have to flatten this 2-D code to compile it...) struct A { virtual f() = 0; }; struct B1 : A { | struct B2 : A { // etc ==> virtual f() = 0; | virtual f() = 0; virtual g() = 0; | virtual h() = 0; }; | }; struct C1 : B1 { | struct C2 : B2 { // etc ==> virtual f(); | virtual f(); virtual g(); | virtual h(); }; | }; IMHO, The redeclarations B1::f() and B2::f() should not be required. Peace, -- ----------------------------------------- "Mmmph! Urghurmph! Grugmph!" Landon Dyer, Apple Computer, Inc. "What's he trying to say?" Development Systems Group (MPW / DSG) "I dunno -- there's a lawyer NOT THE VIEWS OF APPLE COMPUTER crammed in his mouth."