Bug 36796 - Support c++ override keyword
Summary: Support c++ override keyword
Status: RESOLVED DUPLICATE of bug 17920
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: unknown
: P3 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-07-10 20:43 UTC by Simon Douglas
Modified: 2008-12-27 22:02 UTC (History)
10 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Simon Douglas 2008-07-10 20:43:08 UTC
I've seen references on the web to an "override" keyword that allows the compiler to check method signatures are the same where intended, ie. instead of creating a new virtual function when a subclasses override method no longer matches the superclass. (Microsoft compilers.)  This would be a very good api enhancement.

http://msdn.microsoft.com/en-us/library/41w3sh1c.aspx

eg.:

struct I1 {
   virtual void f();
};

struct X : public I1 {
   virtual void f() override {}
};
Comment 1 Arseny Solokha 2008-09-19 13:18:15 UTC
(In reply to comment #0)
This keyword seems to be Microsoft specific, right?
Comment 2 Johan Torp 2008-11-13 08:26:25 UTC
I would also appreciate if gcc supported the override keyword. Consider adding the keyword 'sealed' and perhaps even 'abstract' too.

Johan Torp / www.johantorp.com

Comment 3 Johan Torp 2008-11-13 09:07:14 UTC
I should mention that another option (that is also microsoft specific) is available:

class Base { virtual void vfunc(); }
class Derived
{
// qualify using Base:: to say that you are overiding
// if Base doesn't have a matching vfunc, it is an error
void Base::vfunc();
}; 

See
http://www.cpptalk.net/3-vt23515.html?postdays=0&postorder=asc&start=30


Johan Torp / www.johantorp.com
Comment 4 Andrew Pinski 2008-12-27 22:02:08 UTC

*** This bug has been marked as a duplicate of 17920 ***