Mike and Phani’s Essential C++ Techniques by Michael Hyman, Phani Vaddadi (auth.)

By Michael Hyman, Phani Vaddadi (auth.)

C++ is the language of selection for constructing the main refined home windows courses, however it is stuffed with hidden traps for the unwary. Mike Hyman and Phani Vaddadi's no-nonsense ebook is helping C++ programmers stay away from those traps via offering important ideas gleaned from a mixed 30 years of expertise. during this e-book, you will find a couple of worthy real-world guidance and methods to help you increase your code and coding practices.

Show description

Read or Download Mike and Phani’s Essential C++ Techniques PDF

Similar programming: programming languages books

Objektorientierte Programmierung spielend gelernt: mit dem Java-Hamster-Modell

Bei der Entwicklung von Computerprogrammen haben sich inzwischen sowohl im Ausbildungsbereich als auch in der Industrie objektorientierte Programmiersprachen durchgesetzt, insbesondere die Programmiersprache Java. Dieses Lehrbuch vermittelt ausführlich und anhand vieler Beispiele alle wichtigen Konzepte der objektorientierten Programmierung mit Java.

Mike and Phani’s Essential C++ Techniques

C++ is the language of selection for constructing the main refined home windows courses, however it is full of hidden traps for the unwary. Mike Hyman and Phani Vaddadi's no-nonsense ebook is helping C++ programmers stay away from those traps by means of delivering important thoughts gleaned from a mixed 30 years of expertise.

Additional resources for Mike and Phani’s Essential C++ Techniques

Sample text

So if you assert when the value is too large, the assert will occur whenever the value is too large, no matter how you change your code. Note also that asserts only work during debug builds. As a result, you get all the benefits of the assert when you are testing, but there is no performance or size impact when you create the retail version of the program. cpp Technique 31: Handle the Exception Even If You Assert Category: Avoid crashes Before assert(i < m_clMac); //process stuff 25 Chapter2 After assert(i < m_clMac); if (i < m_clMac) { //process stuff Asserts are wonderful.

Otherwise, you'll just end up copying four bytes. Technique 27: Use const instead of Numeric Literals Category: Write maintainable code; avoid stupid mistakes Before for (int k = o; k < 3; k++) { //First loop } for (k = o; k < 4; k++) { //Second loop. Woops. Wrong number of iterations } After const int NUMITEMS = 3; for (int k = o; k < NUMITEMS; k++) 22 Darn Reasonable Practices { //First loop } for (k = o; k < NUMITEMS; k++) { //Second loop } There are many reasons to use constants instead of literals.

Also, it's just plain sloppy. For example, the "Before" code in this example compares a signed integer with an unsigned integer. The compiler generates a warning. If you don't fix it, the code won't work the way you expect. Use the compiler to treat warnings as errors. From the command line, use the /WX flag. Or, from the environment, do the following: l. Settings. 2. Click on the C/C++ tab. 3. Select the General category. 4. Click on the Warnings as Errors checkbox. Technique 37: Always Use at Least Warning Level 3 Category: Avoid stupid mistakes It takes a lot less time to fix a warning than it does to debug code.

Download PDF sample

Rated 4.06 of 5 – based on 30 votes