From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: *** X-Spam-Status: No, score=3.8 required=5.0 tests=BAYES_00,INVALID_MSGID, RATWARE_MS_HASH,RATWARE_OUTLOOK_NONAME autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fac41,b87849933931bc93 X-Google-Attributes: gidfac41,public X-Google-Thread: f43e6,b87849933931bc93 X-Google-Attributes: gidf43e6,public X-Google-Thread: 1108a1,b87849933931bc93 X-Google-Attributes: gid1108a1,public X-Google-Thread: 109fba,b87849933931bc93 X-Google-Attributes: gid109fba,public X-Google-Thread: 114809,b87849933931bc93 X-Google-Attributes: gid114809,public X-Google-Thread: 103376,b87849933931bc93 X-Google-Attributes: gid103376,public From: "phil" Subject: Re: What is wrong with OO ? Date: 1997/02/17 Message-ID: <01bc1d08$e7562e60$dddc86cd@ntpeh>#1/1 X-Deja-AN: 219435078 References: <5dopri$dei@news4.digex.net> <3301D875.188B@mmm.com> <33049C7C.41C6@wi.leidenuniv.nl> <33088196.68A0@mmm.com> Organization: Zoo Newsgroups: comp.lang.c++,comp.lang.smalltalk,comp.lang.eiffel,comp.lang.ada,comp.object,comp.software-eng Date: 1997-02-17T00:00:00+00:00 List-Id: Pardon me for jumping in but, Kevin J. Hopps wrote in article <33088196.68A0@mmm.com>... > [previous discussion of virtual versus final deleted] > In C++ I have a choice of making functions dynamically bound or not. > Whether I exercise this choice by "saying virtual" or by "not saying > final" really doesn't matter to me much (except then I'd have to say > "final" on all constructors, which seems like unnecessary typing). > Actually, the "final" keyword can be applied to classes, member data, and methods (member functions). Instead of having to say "final" on all constructors, as you suggest above which would be laborious, you can specify that the class itself is final and therefore you cannot derive a class from it. But, you can also mark a constructor as "final" too which might be useful in a slightly different way. Just for your information, if you were not aware of it, "final" applied to member data is the method of creating constants. It is one of the over-loaded uses of the word "final" in Java that I do not agree with. > The only real difference in the two mechanisms (if I understand how > "final" works) is that the absence of "virtual" does not prevent the > overriding of a function in a derived class. This is a feature I might > use if I had it available to me. > As a long time C++ programmer who now also programs in Java, I prefer the "final" method but I do not use it to somehow provide efficiency in function calling (after all, I think all method calls in Java use a dispatch table, aka vtbl, whether they are "final" or not). I prefer final as a means of achieving a "tighter" design over my classes. That is, once behaviour has been established for a particular class, I use "final" to freeze the behaviour. The ability in C++ to "hide" a base class function by "overloading" the signature without using the virtual keyword is indeed more of a flaw than a feature in my opinion. I have programmed in C++ for about 9 years and most of the time that I have seen this overloading type of hiding, it has been a mistake rather than an intent of design. Well, just my 2-bits...isn't dialoging on opinions fun.. phil