Re: Compiler Warning C4373 about virtual methods
"George" <George@discussions.microsoft.com> wrote in message
news:7DBC281E-1B7F-43E6-AC10-6AA69FFC9ADB@microsoft.com
The following code will result in C4373 warning message. In MSDN,
[url]http://msdn2.microsoft.com/en-us/library/bb384874.aspx[/url]
I do not quite understand the following statement,
1. What means "bind"?
Figure out which actual function a name refers to.
2. const is ignored in derived class?
Top-level const qualifiers are ignored in a function declaration. E.g.
void f(int n);
void f(const int n);
both declare the exact same function.
Earlier versions of MSVC compiler got this wrong, and considered the
above declarations distinct. This was particularly noticeable when one
appeared as a virtual function in a base class, and the other in a
derived class: instead of the latter overriding the former, it hid it.
The version you have does the right thing, and considers the declaration
in the derived class an override of that in the base. The warning just
lets you know that it was different in earlier versions, in case you are
working on legacy code and trying to figure out why it suddenly changed
behavior (started calling derived class version where it used to call
base class version).
The bottom line is, be consistent with top-level const and volatile
qualifiers: either don't use them anywhere, or use them everywhere.
Don't mix and match, that only leads to confusion.
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925