Negative tive C ++ Clause 53: Do not underestimate the warning of the Compiler

Source: Internet
Author: User

Class B {
Public:
Virtual void F () const;
};

Class D: Public B {
Public:
Virtual void F ();
};

Here we want to redefine the virtual function B: F, but there is an error. f In B is a const member function, but const is not declared in D. A compiler is like this:

Warning: D: F () hides virtual B: F ()

This compiler tries to tell you that f declared in B is not re-declared in D, but hidden. If you ignore this warning, it will almost certainly lead to incorrect program behavior, followed by many debugging behaviors, just to find out what the compiler has actually detected and told you.

Strive for the honor of "no warning" under the highest warning level of your compiler.

Different compilers have different warning standards. Therefore, you cannot program it rashly and then rely on the compiler to indicate Errors for you.

Before you send a warning, make sure you understand the exact meaning of the intention. This is important.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.