[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [lmi] [PATCH] Use C++11 override keyword
From: |
Vadim Zeitlin |
Subject: |
Re: [lmi] [PATCH] Use C++11 override keyword |
Date: |
Mon, 1 Aug 2016 13:04:31 +0200 |
On Mon, 1 Aug 2016 00:59:48 +0000 Greg Chicares <address@hidden> wrote:
GC> Consider:
GC>
GC> - ~configurable_settings();
GC> + ~configurable_settings() override;
GC>
GC> Is it normal to write "override" on a dtor that's forced to be virtual
GC> because a base class (xml_serializable<configurable_settings> in this
GC> case) has a virtual dtor?
Yes, it is "normal" in the sense that this is correct from C++ point of
view, and it is even also arguably (slightly) useful as this would result
in an error if the base class dtor were changed to not be virtual any more.
This is not something that happens often (or maybe even ever) IME, but as
it doesn't cost anything to guard against it, why not do it.
GC> > The only niggling doubt I have is whether we should have kept the
GC> > "virtual" keyword too instead of dropping it. E.g. consider class
GC> > AboutDialog:
GC>
GC> - virtual int ShowModal();
GC> + virtual int ShowModal() override;
GC> versus
GC> + int ShowModal() override;
GC>
GC> My initial impression is that it's better to drop the redundant
GC> 'virtual' as you have done. Its only purpose was to make the virtual
GC> nature explicit, and 'override' does the same thing. One is written
GC> after the function name, and the other before, but we already have
GC> such variation, e.g.:
GC>
GC> virtual void foo() = 0;
GC> ^^^^^^^ ^^^^
GC> before after
This is a good point that I didn't think about, thanks. I won't change
anything in the patch then.
Thanks for looking at this!
VZ
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: [lmi] [PATCH] Use C++11 override keyword,
Vadim Zeitlin <=