Mike and Phani's Essential C++ Techniques by Michael Hyman, Phani Vaddadi

By Michael Hyman, Phani Vaddadi

C++ is the language of selection for constructing the main subtle home windows courses, however it is full of hidden traps for the unwary. Mike Hyman and Phani Vaddadi's no-nonsense publication is helping C++ programmers keep away from those traps via delivering precious thoughts gleaned from a mixed 30 years of expertise. during this publication, you can find a few beneficial real-world assistance and strategies to help you enhance your code and coding practices. What you’ll learnWho this e-book is for this can be a extraordinary publication for intermediate C++ programmers trying to enhance their C++ programming talents, and complex programmers looking additional innovations and novel ways to fixing tough difficulties. desk of Contents commence with an excellent layout Darn average Practices facing Compiler-Generated Code guidelines and reminiscence Arrays sessions summary Base sessions Constructors Inheritance Operator Overloading Templates Miscellaneous Goop functionality utilizing meeting basic Debugging Stuff particular Debugging Stuff shrewdpermanent tips Reference Counting Dynamic Arrays Strings Bit Manipulation Sorting typical Expression Matching

Show description

By Michael Hyman, Phani Vaddadi

C++ is the language of selection for constructing the main subtle home windows courses, however it is full of hidden traps for the unwary. Mike Hyman and Phani Vaddadi's no-nonsense publication is helping C++ programmers keep away from those traps via delivering precious thoughts gleaned from a mixed 30 years of expertise. during this publication, you can find a few beneficial real-world assistance and strategies to help you enhance your code and coding practices. What you’ll learnWho this e-book is for this can be a extraordinary publication for intermediate C++ programmers trying to enhance their C++ programming talents, and complex programmers looking additional innovations and novel ways to fixing tough difficulties. desk of Contents commence with an excellent layout Darn average Practices facing Compiler-Generated Code guidelines and reminiscence Arrays sessions summary Base sessions Constructors Inheritance Operator Overloading Templates Miscellaneous Goop functionality utilizing meeting basic Debugging Stuff particular Debugging Stuff shrewdpermanent tips Reference Counting Dynamic Arrays Strings Bit Manipulation Sorting typical Expression Matching

Show description

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

Similar programming: programming languages books

Core C Sharp (Visual Studio 2.0 And Dot Net Sep

In view that its free up now not really 3 years in the past, C# has quickly won large utilization. This e-book is written for C# 2. zero, masking the entire new positive aspects in 2. zero, together with generics. as well as its insurance of C#, it additionally offers info at the . internet Framework and periods that C# interacts with. each bankruptcy contains questions and solutions besides advised tasks.

iPhone Apps mit HTML, CSS und JavaScript: Ohne Objective-C und Cocoa zur eigenen App

IPhone Apps mit HTML, CSS and JavaScript: Ohne Objective-C und Cocoa zur eigenen App

Pro J2ME Polish : open source wireless Java tools suite

* the first publication at the J2ME Polish open resource software * Written by way of Robert Virkus, the lead programmer and architect of J2ME Polish * Discusses each element of J2ME Polish in-depth, together with fitting, utilizing, and lengthening * comprises hands-on tutorials that motivate the reader to use their received wisdom

Extra resources for Mike and Phani's Essential C++ Techniques

Sample text

But checking return codes is particularly important when allocating memory. If you allocate memory, make sure the allocation has succeeded before you use the memory. cpp < previous page page_43 next page > < previous page page_44 next page > Page 44 Technique 50 Free Once, Not Often Category: Avoid crashes Before LEX::~LEX() { delete m_pstream; } After LEX::~LEX() { if(m_pstream) delete m_pstream; } Always be sure memory exists before freeing it. Otherwise, you'll get the big kaboom. For example, you may have freed the memory already.

With the "Before" example shown for this technique, you'll catch the incorrect delete in the debugger when you crash. The following incorrect code, however, won't crash. Instead, it will leak memory if m_lpBuffer is null. You may not catch it when you run your program (see Technique 62), but you will catch it if you carefully step through your code in the debugger: if(m_lpBuffer) delete m_lpBuffer; if(m_lpBuffer) delete m_lpscreen; Technique 17 Initialize Local Variables Category: Avoid stupid mistakes Before int SArray::IndexFind(long 1) { int iLeft; int iRight; int iMiddle; long 1M; if(m_clMac == 0) return 0; while(iLeft < iRight) { iMiddle = (iLeft + iRight)/2; < previous page page_14 next page > < previous page page_15 next page > Page 15 After int SArray::IndexFind(long 1) { int iLeft = 0; int iRight = m_clMac; int iMiddle; long lM; if(mclMac == 0) return 0; while(iLeft < iRight) { iMiddle = (iLeft + iRight)/2; It's easy to forget to initialize local variables.

Talk it over. Experiment. Write small isolated programs to test out the concept, algorithm, or new data structure. When you feel comfortable, use it in your work. Good algorithms and data structures make efficient programs. You'll get more benefit from good algorithms than you will from extensive code tuning or rewriting your code in assembly language. Understand the data that you are manipulating. If you understand the data, you are 90 percent on the way to understanding the problem. Here are some things you should ask: What are the storage implications?

Download PDF sample

Rated 4.91 of 5 – based on 43 votes