Dave and others, "I am told C++ users do declare their virtual method overrides using the 'virtual' keyword and omit the keyword to indicate "don't override me anymore" as a coding convention." Not quite...Just a minor clarification, C++ uses the rule : "Once virtual, always virtual". Basically, once declared, anything derived is virtual, though compilers may give warnings. Respectfully, -Ambar Here is an excerpt from Mozilla's C++ portability guide. http://www.mozilla.org/hacking/portable-cpp.html#virtual_on_subclasses Use virtual declaration on all subclass virtual member functions. Non-portable example: class A { virtual void foobar(char*); }; class B : public A { void foobar(char*); }; Another drag. In the class declarations above, A::foobar() is declared as virtual. C++ says that all implementations of void foobar(char*) in subclasses will also be virtual (once virtual, always virtual). This code is really fine, but some compilers want the virtual declaration also used on overloaded functions of the virtual in subclasses. If you don't do it, you get warnings. While this is not a hard error, because this stuff tends to be in headers files, you'll get so many warnings that's you'll go nuts. Better to silence the compiler warnings, by including the virtual declaration in the subclasses. It's also better documentation: Portable example: class A { virtual void foobar(char*); }; class B : public A { virtual void foobar(char*); }; -----Original Message----- From: owner-sv-ec@eda.org [mailto:owner-sv-ec@eda.org] On Behalf Of Rich, Dave Sent: Thursday, March 30, 2006 4:29 PM To: sv-ec@eda.org Subject: RE: [sv-ec] Cliff's 1308 email No-vote - See attached example > > Yes - I had faulty reasoning here. Thanks. After I read the > explanation, I realized that I had forgotten about once-virtual, > always-virtual. Seems like a good coding guideline would be to > override virtual methods with another mothod declared as virtual, > even though it is not required. > [DR>] Cliff, I am told C++ users do declare their virtual method overrides using the 'virtual' keyword and omit the keyword to indicate "don't override me anymore" as a coding convention. DaveReceived on Thu Mar 30 16:03:22 2006
This archive was generated by hypermail 2.1.8 : Thu Mar 30 2006 - 16:03:25 PST