Professional C__ - Marc Gregoire [1]
Low-Level Memory Operations
Smart Pointers
Common Memory Pitfalls
Summary
Chapter 22: Multithreaded Programming with C++
Introduction
Atomic Operations Library
Threads
Mutual Exclusion
Condition Variables
Futures
Example: Multithreaded Logger Class
Thread Pools
Threading Design and Best Practices
Summary
Part IV: C++ Software Engineering
Chapter 23: Maximizing Software Engineering Methods
The Need for Process
Software Life Cycle Models
Software Engineering Methodologies
Building Your Own Process and Methodology
Source Code Control
Summary
Chapter 24: Writing Efficient C++
Overview of Performance and Efficiency
Language-Level Efficiency
Design-Level Efficiency
Profiling
Summary
Chapter 25: Developing Cross-Platform and Cross-Language Applications
Cross-Platform Development
Cross-Language Development
Summary
Chapter 26: Becoming Adept at Testing
Quality Control
Unit Testing
Higher-Level Testing
Tips for Successful Testing
Summary
Chapter 27: Conquering Debugging
The Fundamental Law of Debugging
Bug Taxonomies
Avoiding Bugs
Planning for Bugs
Debugging Techniques
Summary
Chapter 28: Incorporating Design Techniques and Frameworks
“I Can Never Remember How to . . .”
There Must Be a Better Way
Object-Oriented Frameworks
Summary
Chapter 29: Applying Design Patterns
The Iterator Pattern
The Singleton Pattern
The Factory Pattern
The Proxy Pattern
The Adapter Pattern
The Decorator Pattern
The Chain of Responsibility Pattern
The Observer Pattern
Summary
Appendix A: C++ Interviews
Appendix B: Annotated Bibliography
Appendix C: Standard Library Header Files
Introduction
PART I
Introduction to Professional C++
CHAPTER 1: A Crash Course in C++
CHAPTER 2: Designing Professional C++ Programs
CHAPTER 3: Designing with Objects
CHAPTER 4: Designing for Reuse
CHAPTER 5: Coding with Style
Chapter 1
A Crash Course in C++
WHAT’S IN THIS CHAPTER?
A brief overview of the most important parts and syntax of the C++ language
The goal of this chapter is to cover briefly the most important parts of C++ so that you have a base of knowledge before embarking on the rest of the book. This chapter is not a comprehensive lesson in the C++ programming language. The basic points (such as what a program is and the difference between = and ==) are not covered. The esoteric points (Remember what a union is? How about the volatile keyword?) are also omitted. Certain parts of the C language that are less relevant in C++ are also left out, as are parts of C++ that get in-depth coverage in later chapters.
This chapter aims to cover the parts of C++ that programmers encounter every day. For example, if you’ve been away from C++ for a while and you’ve forgotten the syntax of a for loop, you’ll find that syntax in this chapter. Also, if you’re fairly new to C++ and don’t understand what a reference variable is, you’ll learn about that kind of variable here as well.
If you already have significant experience with C++, skim this chapter to make sure that there aren’t any fundamental parts of the language on which you need to brush up. If you’re new to C++, read this chapter carefully and make sure you understand the examples. If you need additional introductory information, consult the titles listed in Appendix B.
THE BASICS OF C++
The C++ language is often viewed as a “better C” or a “superset of C.” Many of the annoyances or rough edges of the C language were addressed when C++ was designed. Because C++ is based on C, much of the syntax you’ll see in this section will look familiar to you if you are an experienced C programmer. The two languages certainly have their differences, though. As evidence, The C++ Programming Language by C++ creator Bjarne Stroustrup (Third Edition; Addison-Wesley Professional, 2000), weighs in at 1030 pages, while Kernighan and Ritchie’s The C Programming Language (Second Edition; Prentice Hall, 1988) is a scant 274 pages. So if