Although traditional paper books seem increasingly unpopular ......
But I personally like reading paper books. Why?
Because I made a cup of coffee, I pulled it to the swivel chair and sat down half-lying. I held C ++ books that were so thick that I could defend myself, and kept myself in the book room, the feeling is that you have already become a senior intellectual. Another situation is that you have to turn on your computer and stare at the screen ...... Alas, I feel like nothing. I can only return to reality and find myself a poor programmer.
A while ago, I flew back to Xiamen from Qingdao, where I got a copy of the People's Daily Overseas Edition (in English only ), sitting in the middle of the box is very lazy to read-in fact, it is very boring-several times move fingers on words that do not understand, think there will be a small form of pop-up translation content ...... In any case, the Force installation effect is very good. The two beautiful women on the side directly cast their eyes on my admiration. The one on the right left me two QQ accounts and talked with me all the way to Xiamen, finally, change the mobile phone number ......
This is the power of knowledge! : B
The same is true for compilers! Think of Scott Meyers, one of the world's top C ++ development authorities) compared with a compiler that has read these two books, compiler C ++ and more powerful C ++.
This is all nonsense.
Open code: blocks (using the Chinese Language Pack Interface), choose "Settings"> "compiler and Debugger" from the main menu, and select the GCC compiler. Then configure its compiler options:
Enable valid tive-C ++ warnings ....
This configuration allows all subsequent C ++ projects created in code: blocks using the GCC compiler to use this option. If you only want to use it in a specific project, you can configure it in a specific project (after opening the project, Main Menu: Project-> build option ).
What are the benefits of this option? Let's test ourselves first:
Code:
- # Include <iostream>
- Using namespace STD;
- Class person
- {
- Public:
- Virtual void say ()
- {
- Cout <"I am a person." <Endl;
- }
- ~ Person ()
- {
- Cout <"bye-bye person." <Endl;
- }
- };
- Class beauty: Public Person
- {
- Public:
- Beauty ()
- : _ P (New INT)
- {
- }
- ~ Beauty ()
- {
- Delete _ P;
- }
- Virtual void say ()
- {
- Cout <"I am a beauty." <Endl;
- }
- PRIVATE:
- Int * _ P;
- };
- Int main ()
- {
- Return 0;
- }
What are the design risks of the above Code? The syntax is certainly no problem. A compiler that has not read books will certainly compile the above code in an obedient manner.
But a compiler that has read a book will give the following warning with simple translation:
| === Temp4book, debug === |
Main. cpp | 7 | warning: 'class person 'has virtual functions and accessible non-virtual destructor
(Row 3, class person has a virtual function, but its destructor are not virtual! Terrible design error)
Main. cpp | 21 | warning: 'class beauty' has pointer data members
(Row 3, class beauty has a pointer data member, next line ......)
Main. cpp | 21 | warning: but does not override 'beauty (const beauty &)'
(However, you have not customized the copy constructor for beauty !)
Main. cpp | 21 | warning: Or 'operator = (const beauty &)'
(Similarly, it does not overload its value assignment operator !)
Main. cpp | 21 | warning: 'class beauty' has virtual functions and accessible non-virtual destructor
(Row 3, class beauty also has a virtual function, but its destructor are not virtual! The reason lies in its base class .)
| |=== Built: 0 errors, 5 warnings ===|
Do you not believe the importance of these warnings? You can buy the two books mentioned above, which are published in China. Here is a simple example:
Code:
- Void test ()
- {
- Beauty B1;
- Beauty b2 = b1;
- }
A serious problem has occurred. Do you know where the problem is? Let's test a question: http://student.csdn.net/space.php? Do = Question & AC = detail> qid = 1839
-------------------------------------------------------------------------------
If you want to communicate with me, please click the following link to become my friend: http://student.csdn.net/invite.php? U= 112600 & C = f635b3cf130f350c