Compiler Warning C4373 about virtual methods



Hello everyone,


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"? Putting function pointer into the vtable of the
related class?

2. const is ignored in derived class?

--------------------
This means the compiler must bind a function reference to the method in
either the base or derived class.

Versions of the compiler prior to Visual C++ 2008 bind the function to the
method in the base class, then issue a warning message. Subsequent versions
of the compiler ignore the const or volatile qualifier, bind the function to
the method in the derived class, then issue warning C4373. This latter
behavior complies with the C++ standard.
--------------------

[Code]
class Base {
public:
virtual int goo (const int input) {return 200;}
};

class Derived : public Base {
public:
virtual int goo (int input) {return 200;} // change const property of
input parameter
};

int main()
{
Derived d;
const int a = 1000;
d.goo (a); // pass const to non-const

return 0;
}
[/Code]

Compile warning message,

1>d:\visual studio
2008\projects\test_overriding1\test_overriding1\main.cpp(8) : warning C4373:
'Derived::goo': virtual function overrides 'Base::goo', previous versions of
the compiler did not override when parameters only differed by const/volatile
qualifiers
1> d:\visual studio
2008\projects\test_overriding1\test_overriding1\main.cpp(3) : see declaration
of 'Base::goo'


regards,
George
.



Relevant Pages

  • Re: NAG ware linking problem
    ... SUBROUTINE antfarm() bind ... I don't have the V51 compiler on my Mac yet, so I can't test this there. ... It does give a warning message for the use of BIND, ...
    (comp.lang.fortran)
  • Re: Databinding Wishlist
    ... bind to say an specific collection element. ... > COMPILER CHECKED BINDING ... > To be able to bind a properties in a way that is checked by the compiler> rather than waiting for a possible runtime error due to a typo. ...
    (microsoft.public.dotnet.framework.windowsforms.databinding)
  • Re: while (1) vs. for ( ;; )
    ... >> I was surprised at how many people reported that a compiler ... >> better expression (lower defect rate, higher productivity, ... There is for some developers. ... effects of a warning message issued by a compiler, ...
    (comp.lang.c)
  • Re: Getting the lr register in a C subroutine
    ... you can't do this in ADS without assembler. ... > The compiler can place the return address whereever it wants, ... The routine I would create is a controled one and all it will do is get ... about happens here, the only problem is the warning message, that to me ...
    (comp.sys.arm)
  • Re: OO in Forth
    ... then the compiler can safely convert the method ... Whether or not there are subclasses with overriding methods has no bearing at all on the compiler's ability to decide to early or late bind. ... let's instantiate two objects and send each the draw: message: ...
    (comp.lang.forth)