Terms 48: Pay attention to the compiler warning
Many programmers always ignore compiler warnings. After all, if the problem is very serious, it will be a mistake, isn't it? This idea is relatively harmful in other languages, but in C , it is certain that the compiler is definitely what happened to you. For example, everyone may have committed this error:
Class B {PUBLIC: Virtual Void f () const;
Class D: public b {public: Virtual void f ();
Originally, I want to use D :: F to redefine virtual functions B :: F, but have an error: in B, f is a constative function, but there is no declaration in the D. As far as I know, a compiler will say this:
Warning: d :: f () hides virtual b :: f ()
For this warning, many of the lack of experience will speak like this, "D :: f, will of course hide B :: f ---- it should be this!" Wrong. The compiler wants to tell you: declaring F in B not re-declared in D, it is completely hidden (see Terms 50: Why is this). Ignore this compiler warning that it will lead to erroneous program behavior. You will keep debugging for reasons, and this error is actually discovered by the compiler.
Of course, after you have accumulated your experience in a warning message for a compiler, you will really understand the meaning of different information (, often different from their surface). Once you have these experiences, you will ignore a lot of warnings. This is no problem, but it is important that before ignoring a warning, you must have an accurate understanding of it wants to tell you.
Just talk about warnings, you should think that warning is closely related to the compiler, so don't be a horse to tiger tiger when programming, you want to find each error for your compiler. For example, the code of the function is hidden, and when it passes different (but using a wide range of) compilers, it may not be warned. The compiler is used to convert C into an executable format, not your private bodyguard. Do you want to get such safety? Use ADA.