Neil Korpusik wrote: > I had the following comments on Dave's latest proposal for Mantis 1308. > 1. Overriding a virtual method > > Page 1, 1st paragraph, 3rd sentence: > > From: > "A virtual method shall override a method in all of its base (parent) > classes, whereas a non-virtual method shall only override a method > in that class and its descendants." > To: > "The implementation of a virtual method shall override that method in all > of its base (parent) classes, whereas the implementation of a non-virtual > method may only override that method in that class and not in any of its > parent classes. I don't like either wording. Why don't we talk about "hiding" and "overriding" as distinct kinds of relationships. I also don't like talking about "overriding ... in all of its base classes". That makes it sound like a virtual function will change the behavior of an object of a base type which clearly is not what is expected. I'd prefer something like: The implementation of a virtual method within a class shall override that method for all objects of that class type and of any derivative type. The implementation of a non-virtual method shall hide any inherited non-virtual method of the same name. A class implementing a non-virtual method which hides an inherited method may still access the base class method via a "super." call or, if the hidden method is static, via a direct class prefixed call (::). An implementation of a method for which the base class provides a virtual method of the same name shall be a virtual override of the base method; the "virtual" keyword is not required. Note that I've incorporated a response to the override issue as well; see below. [...] > 4. Optional 'virtual' keyword > > Page 2, first paragraph. > > "Once a method has been identified as virtual, it shall remain virtual in > any subclass that overrides it. The virtual keyword may be used in later > declarations, but is not required." > > This appears to be an enhancement. Not only that, I don't believe that we > want to add this capability. It should be up to the user to determine if > a method should be virtual or not. > > Neil Neil, do I understand that you want to require the user to have an explicit "virtual" in every derivative class? What if the user does not use the word "virtual" if the base has a virtual method? Does that hide the inherited one or is that an error? I don't see any particular problem with not requiring "virtual" for virtual overrides in derivative classes. Gord. -- -------------------------------------------------------------------- Gordon Vreugdenhil 503-685-0808 Model Technology (Mentor Graphics) gordonv@model.comReceived on Sat Feb 4 21:34:29 2006
This archive was generated by hypermail 2.1.8 : Sat Feb 04 2006 - 21:37:35 PST