c++ - Is there a way to flag (at compile time) "overridden" methods whose signatures don't match base signature? -
basically, want c# compiler functionality of override
keyword in c++ code.
class base { virtual int foo(int) const; }; class derived : public base { virtual int foo(int); // wanted override base, forgot declare const };
as know, above code compile fine, yield strange runtime behavior. love c++ compiler catch poor implementation c#'s override
keyword. there keywords "override" being introduced c++, or stuck #define override virtual
show our intent? (actually, not - hate using preprocessor "extend" language).
if can't wait c++0x, visual c++ has override keyword. (since 2005 believe). there syntax is:
virtual int foo(int) override;
you're not obliged type it, however. , non-standard microsoft extension.
Comments
Post a Comment