Compiler Warning C4373 about virtual methods

Discussion in 'C Programming' started by George2, Feb 25, 2008.

  1. George2

    George2

    Joined:
    Feb 12, 2008
    Messages:
    108
    Hello everyone,


    The following code will result in C4373 warning message. In MSDN,

    http://msdn2.microsoft.com/en-us/library/bb384874.aspx

    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;
    }
    
    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
    George2, Feb 25, 2008
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jim Fischer
    Replies:
    3
    Views:
    435
    Jim Fischer
    Jul 31, 2003
  2. Pete Becker
    Replies:
    0
    Views:
    1,373
    Pete Becker
    Feb 10, 2005
  3. B. Williams

    warning C4267 and warning C4996

    B. Williams, Oct 26, 2006, in forum: C++
    Replies:
    17
    Views:
    2,629
    robertwessel2@yahoo.com
    Oct 27, 2006
  4. pentologer@gmail.com

    WARNING! Prosoftstore.com is a SCAM! WARNING!

    pentologer@gmail.com, Jul 8, 2007, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    318
    pentologer@gmail.com
    Jul 8, 2007
  5. Kenneth McDonald
    Replies:
    5
    Views:
    313
    Kenneth McDonald
    Sep 26, 2008
Loading...

Share This Page