Muutke küpsiste eelistusi

Professional Cplusplus [Pehme köide]

  • Formaat: Paperback / softback, 984 pages, kõrgus x laius x paksus: 235x185x43 mm, kaal: 1612 g, Contains 1 Digital online
  • Ilmumisaeg: 09-Sep-2014
  • Kirjastus: John Wiley & Sons Inc
  • ISBN-10: 1118858050
  • ISBN-13: 9781118858059
Teised raamatud teemal:
  • Pehme köide
  • Hind: 63,99 €*
  • * saadame teile pakkumise kasutatud raamatule, mille hind võib erineda kodulehel olevast hinnast
  • See raamat on trükist otsas, kuid me saadame teile pakkumise kasutatud raamatule.
  • Kogus:
  • Lisa ostukorvi
  • Tasuta tarne
  • Lisa soovinimekirja
  • Formaat: Paperback / softback, 984 pages, kõrgus x laius x paksus: 235x185x43 mm, kaal: 1612 g, Contains 1 Digital online
  • Ilmumisaeg: 09-Sep-2014
  • Kirjastus: John Wiley & Sons Inc
  • ISBN-10: 1118858050
  • ISBN-13: 9781118858059
Teised raamatud teemal:
A code-intensive guide to designing and building applications with the latest release of C++ covers changes to core language features and syntax, the latest standard library features, and best practices for programming style, testing, and debugging.

Master complex C++ programming with this helpful, in-depth resource

From game programming to major commercial software applications, C++ is the language of choice. It is also one of the most difficult programming languages to master. While most competing books are geared toward beginners, Professional C++, Third Edition, shows experienced developers how to master the latest release of C++, explaining little known features with detailed code examples users can plug into their own codes. More advanced language features and programming techniques are presented in this newest edition of the book, whose earlier editions have helped thousands of coders get up to speed with C++. Become familiar with the full capabilities offered by C++, and learn the best ways to design and build applications to solve real-world problems.

Professional C++, Third Edition has been substantially revised and revamped from previous editions, and fully covers the latest (2014) C++ standard. Discover how to navigate the significant changes to the core language features and syntax, and extensions to the C++ Standard Library and its templates. This practical guide details many poorly understood elements of C++ and highlights pitfalls to avoid.

  • Best practices for programming style, testing, and debugging
  • Working code that readers can plug into their own apps
  • In-depth case studies with working code
  • Tips, tricks, and workarounds with an emphasis on good programming style

Move forward with this comprehensive, revamped guide to professional coding with C++.

Introduction xli
PART I INTRODUCTION TO PROFESSIONAL C++
Chapter 1 A Crash Course In C++ And The STL
3(44)
The Basics of C++
4(1)
The Obligatory Hello, World
4(1)
Comments
4(1)
Preprocessor Directives
5(1)
The main() Function
6(1)
I/O Streams
6(1)
Namespaces
7(2)
Variables
9(2)
Literals
11(1)
Operators
11(2)
Types
13(1)
Enumerated Types
13(2)
Structs
15(1)
Conditionals
15(1)
if/else Statements
16(1)
switch Statements
16(1)
The Conditional Operator
17(1)
Logical Evaluation Operators
17(1)
Arrays
18(2)
std::array
20(1)
Loops
20(1)
The while Loop
20(1)
The do/while Loop
21(1)
The for Loop
21(1)
The Range-Based for Loop
21(1)
Functions
22(1)
Alternative Function Syntax
23(1)
Function Return Type Deduction
23(1)
Type Inference Part 1
24(1)
The auto Keyword
24(1)
The decltype Keyword
24(1)
Those Are the Basics
24(1)
Diving Deeper into C++
25(1)
Pointers and Dynamic Memory
25(1)
The Stack and the Heap
25(1)
Working with Pointers
26(1)
Dynamically Allocated Arrays
27(1)
Null Pointer Constant
28(1)
Smart Pointers
28(1)
References
29(1)
Strings in C++
30(1)
Exceptions
30(2)
The Many Uses of const
32(1)
const Constants
32(1)
const to Protect Parameters
32(1)
const References
32(1)
Type Inference Part 2
33(1)
decltype(auto)
33(1)
C++ as an Object-Oriented Language
34(1)
Defining a Class
34(2)
The Standard Library
36(1)
std::vector
36(1)
Your First Useful C++ Program
37(1)
An Employee Records System
37(1)
The Employee Class
38(1)
Employee.h
38(1)
Employee.cpp
39(2)
EmployeeTest.cpp
41(1)
The Database Class
41(1)
Database.h
41(1)
Database.cpp
42(1)
DatabaseTest.cpp
43(1)
The User Interface
44(1)
UserInterface.cpp
44(2)
Evaluating the Program
46(1)
Summary
46(1)
Chapter 2 Working With Strings
47(10)
Dynamic Strings
47(1)
C-Style Strings
48(2)
String Literals
50(1)
The C++ string Class
51(1)
What Is Wrong with C-Style Strings?
51(1)
Using the string Class
51(2)
std::string Literals
53(1)
Numeric Conversions
53(1)
Raw String Literals
54(1)
Nonstandard Strings
55(1)
Summary
55(2)
Chapter 3 Coding With Style
57(22)
The Importance of Looking Good
57(1)
Thinking Ahead
58(1)
Elements of Good Style
58(1)
Documenting Your Code
58(1)
Reasons to Write Comments
58(1)
Commenting to Explain Usage
58(2)
Commenting to Explain Complicated Code
60(1)
Commenting to Convey Metainformation
61(1)
Commenting Styles
62(1)
Commenting Every Line
62(2)
Prefix Comments
64(1)
Fixed-Format Comments
64(1)
Ad Hoc Comments
65(1)
Self-Documenting Code
66(1)
Comments in This Book
66(1)
Decomposition
66(1)
Decomposition through Refactoring
67(1)
Decomposition by Design
67(1)
Decomposition in This Book
68(1)
Naming
68(1)
Choosing a Good Name
68(1)
Naming Conventions
69(1)
Counters
69(1)
Prefixes
69(1)
Getters and Setters
70(1)
Capitalization
70(1)
Namespaced Constants
70(1)
Hungarian Notation
70(1)
Using Language Features with Style
71(1)
Use Constants
71(1)
Use References Instead of Pointers
71(1)
Use Custom Exceptions
72(1)
Formatting
72(1)
The Curly Brace Alignment Debate
72(2)
Coming to Blows over Spaces and Parentheses
74(1)
Spaces and Tabs
74(1)
Stylistic Challenges
74(1)
Summary
75(4)
PART II PROFESSIONAL C++ SOFTWARE DESIGN
Chapter 4 Designing Professional C++ Programs
79(28)
What Is Programming Design?
80(1)
The Importance of Programming Design
80(2)
Designing for C++
82(1)
Two Rules for C++ Design
83(1)
Abstraction
84(1)
Benefiting from Abstraction
84(1)
Incorporating Abstraction in Your Design
84(1)
Reuse
85(1)
Reusing Code
86(1)
Writing Reusable Code
86(1)
Reusing Ideas
87(1)
Reusing Code
87(1)
A Note on Terminology
87(1)
Deciding Whether or Not to Reuse Code
88(1)
Advantages to Reusing Code
88(1)
Disadvantages to Reusing Code
89(1)
Putting It Together to Make a Decision
90(1)
Strategies for Reusing Code
90(1)
Understand the Capabilities and Limitations
90(1)
Understand the Performance
91(3)
Understand Platform Limitations
94(1)
Understand Licensing and Support
94(1)
Know Where to Find Help
94(1)
Prototype
95(1)
Bundling Third-Party Applications
95(1)
Open-Source Libraries
96(1)
The Open-Source Movements
96(1)
Finding and Using Open-Source Libraries
96(1)
Guidelines for Using Open-Source Code
97(1)
The C++ Standard Library
97(1)
C Standard Library
97(1)
Deciding Whether or Not to Use the STL
98(1)
Designing with Patterns and Techniques
98(1)
Designing a Chess Program
99(1)
Requirements
99(1)
Design Steps
99(1)
Divide the Program into Subsystems
99(2)
Choose Threading Models
101(1)
Specify Class Hierarchies for Each Subsystem
101(1)
Specify Classes, Data Structures, Algorithms, and Patterns for Each Subsystem
102(2)
Specify Error Handling for Each Subsystem
104(1)
Summary
105(2)
Chapter 5 Designing With Objects
107(20)
Am I Thinking Procedurally?
108(1)
The Object-Oriented Philosophy
108(1)
Classes
108(1)
Components
109(1)
Properties
109(1)
Behaviors
110(1)
Bringing It All Together
110(1)
Living in a World of Objects
111(1)
Overobjectification
111(1)
Overly General Objects
112(1)
Object Relationships
113(1)
The Has-A Relationship
113(1)
The Is-A Relationship (Inheritance)
114(1)
Inheritance Techniques
115(1)
Polymorphism versus Code Reuse
116(1)
The Fine Line between Has-A and Is-A
116(3)
The Not-A Relationship
119(1)
Hierarchies
120(1)
Multiple Inheritance
121(1)
Mixin Classes
122(1)
Abstraction
122(1)
Interface versus Implementation
123(1)
Deciding on an Exposed Interface
123(1)
Consider the Audience
123(1)
Consider the Purpose
124(1)
Consider the Future
125(1)
Designing a Successful Abstraction
125(1)
Summary
126(1)
Chapter 6 Designing For Reuse
127(16)
The Reuse Philosophy
127(1)
How to Design Reusable Code
128(1)
Use Abstraction
129(1)
Structure Your Code for Optimal Reuse
130(1)
Avoid Combining Unrelated or Logically Separate Concepts
130(2)
Use Templates for Generic Data Structures and Algorithms
132(2)
Provide Appropriate Checks and Safeguards
134(1)
Design Usable Interfaces
135(1)
Design Interfaces That Are Easy to Use
135(3)
Design General-Purpose Interfaces
138(1)
Reconciling Generality and Ease of Use
139(1)
Supply Multiple Interfaces
139(1)
Make Common Functionality Easy to Use
140(1)
Summary
140(3)
PART III CODING THE PROFESSIONAL WAY
Chapter 7 Gaining Proficiency With Classes And Objects
143(34)
Introducing the Spreadsheet Example
144(1)
Writing Classes
144(1)
Class Definitions
144(1)
Class Members
145(1)
Access Control
145(2)
Order of Declarations
147(1)
Defining Methods
147(1)
Accessing Data Members
148(1)
Calling Other Methods
148(2)
The this Pointer
150(1)
Using Objects
151(1)
Objects on the Stack
151(1)
Objects on the Heap
151(1)
Object Life Cycles
152(1)
Object Creation
153(1)
Writing Constructors
153(1)
Using Constructors
154(1)
Providing Multiple Constructors
155(1)
Default Constructors
156(4)
Constructor Initializers
160(2)
Copy Constructors
162(3)
Initializer-List Constructors
165(2)
In-Class Member Initializers
167(1)
Delegating Constructors
167(1)
Summary of Compiler-Generated Constructors
168(1)
Object Destruction
169(1)
Assigning to Objects
170(1)
Declaring an Assignment Operator
171(1)
Defining an Assignment Operator
172(1)
Explicitly Defaulted and Deleted Assignment Operator
173(1)
Distinguishing Copying from Assignment
173(1)
Objects as Return Values
173(1)
Copy Constructors and Object Members
174(1)
Summary
175(2)
Chapter 8 Mastering Classes And Objects
177(40)
Dynamic Memory Allocation in Objects
178(1)
The Spreadsheet Class
178(2)
Freeing Memory with Destructors
180(1)
Handling Copying and Assignment
180(5)
The Spreadsheet Copy Constructor
185(1)
The Spreadsheet Assignment Operator
185(2)
Common Helper Routines for Copy Constructor and Assignment Operator
187(1)
Disallowing Assignment and Pass-By-Value
188(1)
Different Kinds of Data Members
188(1)
static Data Members
188(1)
Accessing static Data Members within Class Methods
189(1)
Accessing static Data Members Outside Methods
190(1)
const Data Members
190(1)
Reference Data Members
191(1)
const Reference Data Members
192(1)
More about Methods
193(1)
static Methods
193(1)
const Methods
194(1)
mutable Data Members
195(1)
Method Overloading
195(2)
Default Parameters
197(1)
Inline Methods
197(2)
Nested Classes
199(2)
Enumerated Types Inside Classes
201(1)
Friends
202(1)
Operator Overloading
203(1)
Example: Implementing Addition for SpreadsheetCells
203(1)
First Attempt: The add Method
203(1)
Second Attempt: Overloaded operator+ as a Method
204(2)
Third Attempt: Global operator+
206(1)
Overloading Arithmetic Operators
207(1)
Overloading the Arithmetic Shorthand Operators
208(2)
Overloading Comparison Operators
210(1)
Building Types with Operator Overloading
211(1)
Building Stable Interfaces
212(1)
Using Interface and Implementation Classes
212(3)
Summary
215(2)
Chapter 9 Discovering Inheritance Techniques
217(56)
Building Classes with Inheritance
218(1)
Extending Classes
218(1)
A Client's View of Inheritance
219(1)
A Derived Class's View of Inheritance
220(1)
Preventing Inheritance
221(1)
Overriding Methods
222(1)
How I Learned to Stop Worrying and Make Everything virtual
222(1)
Syntax for Overriding a Method
223(1)
A Client's View of Overridden Methods
223(2)
Preventing Overriding
225(1)
Inheritance for Reuse
225(1)
The WeatherPrediction Class
225(1)
Adding Functionality in a Derived Class
226(2)
Replacing Functionality in a Derived Class
228(1)
Respect Your Parents
229(1)
Parent Constructors
229(1)
Parent Destructors
230(2)
Referring to Parent Names
232(3)
Casting Up and Down
235(1)
Inheritance for Polymorphism
236(1)
Return of the Spreadsheet
236(1)
Designing the Polymorphic Spreadsheet Cell
237(1)
The Spreadsheet Cell Base Class
237(1)
A First Attempt
238(1)
Pure Virtual Methods and Abstract Base Classes
238(1)
Base Class Source Code
239(1)
The Individual Derived Classes
239(1)
String Spreadsheet Cell Class Definition
240(1)
String Spreadsheet Cell Implementation
240(1)
Double Spreadsheet Cell Class Definition and Implementation
241(1)
Leveraging Polymorphism
242(1)
Future Considerations
243(1)
Multiple Inheritance
244(1)
Inheriting from Multiple Classes
244(2)
Naming Collisions and Ambiguous Base Classes
246(1)
Name Ambiguity
246(1)
Ambiguous Base Classes
247(1)
Uses for Multiple Inheritance
248(1)
Interesting and Obscure Inheritance Issues
249(1)
Changing the Overridden Method's Characteristics
249(1)
Changing the Method Return Type
249(1)
Changing the Method Parameters
250(3)
Inherited Constructors
253(3)
Special Cases in Overriding Methods
256(1)
The Base Class Method Is static
257(1)
The Base Class Method Is Overloaded
258(1)
The Base Class Method Is private or protected
259(1)
The Base Class Method Has Default Arguments
260(1)
The Base Class Method Has a Different Access Level
261(3)
Copy Constructors and Assignment Operator in Derived Classes
264(1)
The Truth about virtual
265(1)
Hiding Instead of Overriding
265(1)
How virtual Is Implemented
266(1)
The Justification for virtual
267(1)
The Need for virtual Destructors
267(1)
Run-Time Type Facilities
268(2)
Non-Public Inheritance
270(1)
Virtual Base Classes
270(1)
Summary
271(2)
Chapter 10 C++ Quirks, Oddities, And Incidentals
273(42)
References
274(1)
Reference Variables
274(1)
Modifying References
275(1)
References to Pointers and Pointers to References
275(1)
Reference Data Members
276(1)
Reference Parameters
276(1)
References from Pointers
277(1)
Pass-by-Reference Versus Pass-by-Value
277(1)
Reference Return Values
278(1)
Deciding between References and Pointers
278(3)
Rvalue References
281(2)
Move Semantics
283(3)
Keyword Confusion
286(1)
The const Keyword
286(1)
const Variables and Parameters
287(2)
const Methods
289(1)
The constexpr Keyword
289(2)
The static Keyword
291(1)
static Data Members and Methods
291(1)
static Linkage
291(2)
static Variables in Functions
293(1)
Order of Initialization of Nonlocal Variables
294(1)
Order of Destruction of Nonlocal Variables
294(1)
Types and Casts
295(1)
typedefs
295(1)
typedefs for Function Pointers
296(1)
Type Aliases
297(1)
Casts
297(1)
const cast
298(1)
static cast
298(1)
reinterpret cast
299(1)
dynamic cast
300(1)
Summary of Casts
301(1)
Scope Resolution
302(1)
C++11 / C++14
303(1)
Uniform Initialization
303(2)
Initializer Lists
305(1)
Explicit Conversion Operators
305(1)
Attributes
306(1)
User-Defined Literals
307(1)
Standard User-Defined Literals
308(1)
Header Files
309(1)
C Utilities
310(1)
Variable-Length Argument Lists
310(1)
Accessing the Arguments
311(1)
Why You Shouldn't Use C-Style Variable-Length Argument Lists
312(1)
Preprocessor Macros
312(1)
Summary
313(2)
Chapter 11 Writing Generic Code With Templates
315(30)
Overview of Templates
316(1)
Class Templates
317(1)
Writing a Class Template
317(1)
Coding without Templates
317(3)
A Template Grid Class
320(3)
Using the Grid Template
323(1)
Angle Brackets
324(1)
How the Compiler Processes Templates
324(1)
Selective Instantiation
325(1)
Template Requirements on Types
325(1)
Distributing Template Code between Files
325(1)
Template Definitions in Header Files
325(1)
Template Definitions in Source Files
326(1)
Template Parameters
327(1)
Non-Type Template Parameters
327(2)
Default Values for Type Parameters
329(1)
Method Templates
330(2)
Method Templates with Non-Type Parameters
332(2)
Class Template Specialization
334(2)
Deriving from Class Templates
336(1)
Inheritance versus Specialization
337(1)
Alias Templates
338(1)
Alternative Function Syntax
338(1)
Function Templates
339(1)
Function Template Specialization
340(1)
Function Template Overloading
341(1)
Function Template Overloading and Specialization Together
342(1)
Friend Function Templates of Class Templates
342(1)
Variable Templates
343(1)
Summary
343(2)
Chapter 12 Demystifying C++ I/O
345(24)
Using Streams
346(1)
What Is a Stream, Anyway?
346(1)
Stream Sources and Destinations
347(1)
Output with Streams
347(1)
Output Basics
347(1)
Methods of Output Streams
348(2)
Handling Output Errors
350(1)
Output Manipulators
351(2)
Input with Streams
353(1)
Input Basics
353(1)
Input Methods
354(3)
Handling Input Errors
357(1)
Input Manipulators
358(1)
Input and Output with Objects
359(1)
String Streams
360(2)
File Streams
362(1)
Jumping around with seek() and tell()
363(2)
Linking Streams Together
365(1)
Bidirectional I/O
366(1)
Summary
367(2)
Chapter 13 Handling Errors
369(42)
Errors and Exceptions
370(1)
What Are Exceptions, Anyway?
370(1)
Why Exceptions in C++ Are a Good Thing
371(1)
Recommendation
372(1)
Exception Mechanics
372(1)
Throwing and Catching Exceptions
373(3)
Exception Types
376(1)
Catching Exception Objects by const and Reference
377(1)
Throwing and Catching Multiple Exceptions
378(1)
Matching and const
379(1)
Matching Any Exception
380(1)
Uncaught Exceptions
380(2)
Throw Lists
382(1)
Unexpected Exceptions
383(2)
Changing the Throw List in Overridden Methods
385(1)
Are Throw Lists Useful?
386(1)
Exceptions and Polymorphism
387(1)
The Standard Exception Hierarchy
387(1)
Catching Exceptions in a Class Hierarchy
388(2)
Writing Your Own Exception Classes
390(2)
Nested Exceptions
392(2)
Stack Unwinding and Cleanup
394(2)
Use Smart Pointers
396(1)
Catch, Cleanup, and Rethrow
396(1)
Common Error-Handling Issues
397(1)
Memory Allocation Errors
397(1)
Non-Throwing new
398(1)
Customizing Memory Allocation Failure Behavior
399(1)
Errors in Constructors
400(2)
Function-Try-Blocks for Constructors
402(2)
Errors in Destructors
404(1)
Putting It All Together
405(4)
Summary
409(2)
Chapter 14 Overloading C++ Operators
411(32)
Overview of Operator Overloading
412(1)
Why Overload Operators?
412(1)
Limitations to Operator Overloading
412(1)
Choices in Operator Overloading
413(1)
Method or Global Function
413(1)
Choosing Argument Types
414(1)
Choosing Return Types
414(1)
Choosing Behavior
415(1)
Operators You Shouldn't Overload
415(1)
Summary of Overloadable Operators
415(4)
Rvalue References
419(1)
Relational Operators
419(1)
Overloading the Arithmetic Operators
420(1)
Overloading Unary Minus and Unary Plus
420(1)
Overloading Increment and Decrement
420(1)
Overloading the Bitwise and Binary Logical Operators
421(1)
Overloading the Insertion and Extraction Operators
422(1)
Overloading the Subscripting Operator
423(3)
Providing Read-Only Access with operator[ ]
426(1)
Non-Integral Array Indices
427(1)
Overloading the Function Call Operator
428(1)
Overloading the Dereferencing Operators
429(1)
Implementing operator*
430(1)
Implementing operator→
431(1)
What in the World Is operators*?
432(1)
Writing Conversion Operators
432(1)
Ambiguity Problems with Conversion Operators
433(1)
Conversions for Boolean Expressions
434(2)
Overloading the Memory Allocation and Deallocation Operators
436(1)
How new and delete Really Work
436(1)
The New-Expression and operator new
437(1)
The Delete-Expression and operator delete
437(1)
Overloading operator new and operator delete
437(3)
Explicitly Deleting/Defaulting operator new and operator delete
440(1)
Overloading operator new and operator delete with Extra Parameters
440(2)
Summary
442(1)
Chapter 15 Overview Of The C++ Standard Library
443(24)
Coding Principles
444(1)
Use of Templates
444(1)
Use of Operator Overloading
444(1)
Overview of the C++ Standard Library
445(1)
Strings
445(1)
Regular Expressions
445(1)
I/O Streams
445(1)
Smart Pointers
446(1)
Exceptions
446(1)
Mathematical Utilities
446(1)
Time Utilities
447(1)
Random Numbers
447(1)
Initializer Lists
447(1)
Pair and Tuple
447(1)
Function Objects
448(1)
Multithreading
448(1)
Type Traits
448(1)
The Standard Template Library
448(1)
STL Containers
448(8)
STL Algorithms
456(9)
What's Missing from the STL
465(1)
Summary
465(2)
Chapter 16 Understanding Containers And Iterators
467(64)
Containers Overview
468(1)
Requirements on Elements
468(2)
Exceptions and Error Checking
470(1)
Iterators
470(2)
Common Iterator typedefs and Methods
472(1)
Sequential Containers
473(1)
vector
473(1)
vector Overview
473(2)
vector Details
475(11)
vector Example: A Round-Robin Class
486(4)
The vector<bool> Specialization
490(1)
deque
491(1)
list
491(1)
Accessing Elements
492(1)
Iterators
492(1)
Adding and Removing Elements
492(1)
list Size
492(1)
Special list Operations
492(3)
Forward_list
495(2)
array
497(1)
Container Adapters
498(1)
queue
498(1)
queue Operations
499(1)
queue Example: A Network Packet Buffer
499(2)
priority queue
501(1)
priority queue Operations
502(1)
priority queue Example: An Error Correlator
502(2)
stack
504(1)
stack Operations
504(1)
stack Example: Revised Error Correlator
504(1)
Associative Containers
504(1)
The pair Utility Class
504(1)
map
505(1)
Constructing maps
506(1)
Inserting Elements
506(2)
map Iterators
508(1)
Looking Up Elements
509(1)
Removing Elements
509(1)
map Example: Bank Account
510(2)
multimap
512(1)
multimap Example: Buddy Lists
512(3)
set
515(1)
set Example: Access Control List
515(1)
multiset
516(1)
Unordered Associative Containers/Hash Tables
516(1)
Hash Functions
517(2)
Unordered_map
519(2)
Unordered_map Example: Phone Book
521(1)
Unordered_multimap
522(1)
Unordered_set/unordered multiset
522(1)
Other Containers
523(1)
Standard C-Style Arrays
523(1)
strings
524(1)
Streams
524(1)
bitset
524(1)
bitset Basics
525(1)
Bitwise Operators
525(1)
bitset Example: Representing Cable Channels
526(3)
Summary
529(2)
Chapter 17 Mastering STL Algorithms
531(44)
Overview of Algorithms
532(1)
The find and find if Algorithms
532(3)
The accumulate Algorithms
535(1)
Move Semantics with Algorithms
536(1)
Lambda Expressions
536(1)
Syntax
536(2)
Full Syntax
538(1)
Generic Lambda Expressions
539(1)
Lambda Capture Expressions
539(1)
Lambda Expressions as Return Type
540(1)
Lambda Expressions as Parameters
541(1)
Examples with STL Algorithms
541(1)
count if
542(1)
generate
542(1)
Function Objects
542(1)
Arithmetic Function Objects
543(1)
Transparent Operator Functors
544(1)
Comparison Function Objects
544(1)
Logical Function Objects
545(1)
Bitwise Function Objects
546(1)
Function Object Adapters
546(1)
Binders
546(2)
Negators
548(1)
Calling Member Functions
548(1)
Writing Your Own Function Objects
549(1)
Algorithm Details
550(1)
Iterators
551(1)
Non-Modifying Sequence Algorithms
551(1)
Search Algorithms
551(2)
Comparison Algorithms
553(2)
Utility Algorithms
555(1)
Modifying Sequence Algorithms
556(1)
transform
556(2)
copy
558(1)
move
559(1)
replace
560(1)
remove
561(1)
unique
562(1)
reverse
562(1)
shuffle
562(1)
Operational Algorithms
562(2)
Partition Algorithms
564(1)
Sorting Algorithms
565(1)
Binary Search Algorithms
566(1)
Set Algorithms
566(3)
Minimum/Maximum Algorithms
569(1)
Numerical Processing Algorithms
570(1)
Inner_product
570(1)
iota
570(1)
Algorithms Example: Auditing Voter Registrations
570(1)
The Voter Registration Audit Problem Statement
571(1)
The auditVoterRolls Function
571(1)
The getDuplicates Function
572(1)
Testing the auditVoterRolls Function
573(1)
Summary
573(2)
Chapter 18 String Localization And Regular Expressions
575(26)
Localization
575(1)
Localizing String Literals
576(1)
Wide Characters
576(1)
Non-Western Character Sets
577(2)
Locales and Facets
579(1)
Using Locales
579(1)
Using Facets
580(1)
Regular Expressions
581(1)
ECMAScript Syntax
582(1)
Anchors
582(1)
Wildcards
582(1)
Alternation
582(1)
Grouping
583(1)
Repetition
583(1)
Precedence
584(1)
Character Set Matches
584(2)
Word Boundaries
586(1)
Back References
587(1)
Lookahead
587(1)
Regular Expressions and Raw String Literals
587(1)
The regex Library
588(1)
Regex_match()
589(1)
Regex_match() Example
589(3)
Regex_search()
592(1)
Regex_search() Example
592(1)
Regex_iterator
593(1)
Regex_iterator Example
593(1)
Regex_token_iterator
594(1)
Regex_token_iterator Examples
595(1)
Regex_replace()
596(1)
Regex_replace() Examples
597(2)
Summary
599(2)
Chapter 19 Additional Library Utilities
601(26)
std::function
601(2)
Ratios
603(3)
The Chrono Library
606(1)
Duration
606(4)
Clock
610(1)
Time Point
611(1)
Random Number Generation
612(1)
Random Number Engines
613(2)
Random Number Engine Adapters
615(1)
Predefined Engines and Engine Adapters
616(1)
Generating Random Numbers
616(2)
Random Number Distributions
618(3)
Tuples
621(3)
Summary
624(3)
PART IV MASTERING ADVANCED FEATURES OF C++
Chapter 20 Customizing And Extending The STL
627(46)
Allocators
628(1)
Iterator Adapters
628(1)
Reverse Iterators
629(1)
Stream Iterators
630(1)
Insert Iterators
631(1)
Move Iterators
632(2)
Extending the STL
634(1)
Why Extend the STL?
634(1)
Writing an STL Algorithm
634(1)
find all()
634(1)
Iterator Traits
635(1)
Writing an STL Container
636(1)
A Basic Hash Map
636(8)
Making hash map an STL Container
644(13)
Note on Allocators
657(1)
Note on Reversible Containers
658(1)
Making hash map an Associative Container
658(12)
Note on Sequential Containers
670(1)
Summary
671(2)
Chapter 21 Advanced Templates
673(34)
More about Template Parameters
673(1)
More about Template Type Parameters
674(2)
Default Values for Template Type Parameters
676(1)
Introducing Template Template Parameters
676(2)
More about Non-Type Template Parameters
678(1)
Reference and Pointer Non-Type Template Parameters
679(1)
Class Template Partial Specialization
679(2)
Another Form of Partial Specialization
681(2)
Emulating Function Partial Specialization with Overloading
683(1)
More on Deduction
684(1)
Template Recursion
685(1)
An N-Dimensional Grid: First Attempt
685(1)
A Real N-Dimensional Grid
686(3)
Type Inference
689(1)
auto and decltype with Templates
689(2)
Variadic Templates
691(1)
Type-Safe Variable-Length Argument Lists
692(2)
Variable Number of Mixin Classes
694(1)
Metaprogramming
695(1)
Factorial at Compile Time
696(1)
Loop Unrolling
696(2)
Printing Tuples
698(1)
Type Traits
699(1)
Using Type Categories
700(2)
Using Type Relations
702(1)
Using enable_if
703(2)
Metaprogramming Conclusion
705(1)
Summary
705(2)
Chapter 22 Memory Management
707(34)
Working with Dynamic Memory
708(1)
How to Picture Memory
708(1)
Allocation and Deallocation
709(1)
Using new and delete
710(1)
What about My Good Friend malloc?
710(1)
When Memory Allocation Fails
711(1)
Arrays
711(1)
Arrays of Basic Types
712(1)
Arrays of Objects
713(1)
Deleting Arrays
714(1)
Multi-Dimensional Arrays
715(3)
Working with Pointers
718(1)
A Mental Model for Pointers
718(1)
Casting with Pointers
719(1)
Array-Pointer Duality
720(1)
Arrays Are Pointers!
720(2)
Not All Pointers Are Arrays!
722(1)
Low-Level Memory Operations
722(1)
Pointer Arithmetic
722(1)
Custom Memory Management
723(1)
Garbage Collection
724(1)
Object Pools
725(1)
Function Pointers
725(2)
Pointers to Methods and Data Members
727(1)
Smart Pointers
727(1)
The Old Deprecated auto_ptr
728(1)
The unique_ptr and shared_ptr Smart Pointers
729(1)
Unique_ptr
729(2)
Shared_ptr
731(2)
Move Semantics
733(1)
Weak_ptr
734(1)
Common Memory Pitfalls
734(1)
Underallocating Strings
734(1)
Accessing Out-of-Bounds Memory
735(1)
Memory Leaks
736(1)
Finding and Fixing Memory Leaks in Windows with Visual C++
737(1)
Finding and Fixing Memory Leaks in Linux with Valgrind
738(1)
Double-Deleting and Invalid Pointers
739(1)
Summary
740(1)
Chapter 23 Multithreaded Programming With C++
741(40)
Introduction
742(1)
Race Conditions
743(2)
Deadlocks
745(1)
Tearing
746(1)
Cache Coherency
746(1)
Threads
746(1)
Thread with Function Pointer
746(2)
Thread with Function Object
748(2)
Thread with Lambda
750(1)
Thread with Member Function
751(1)
Thread Local Storage
751(1)
Cancelling Threads
752(1)
Retrieving Results from Threads
752(1)
Copying and Rethrowing Exceptions
752(3)
Atomic Operations Library
755(1)
Atomic Type Example
755(2)
Atomic Operations
757(1)
Mutual Exclusion
758(1)
Mutex Classes
759(1)
Non-Timed Mutex Classes
759(1)
Timed Mutex Classes
760(1)
Locks
761(1)
Lock_guard
761(1)
Unique_lock
761(1)
Shared_lock
762(1)
Acquiring Multiple Locks at Once
762(1)
std::call_once
763(1)
Examples Using Mutual Exclusion Objects
764(1)
Thread-Safe Writing to Streams
764(1)
Using Timed Locks
765(1)
Double-Checked Locking
766(1)
Condition Variables
767(3)
Futures
770(2)
Exception Handling
772(1)
Example: Multithreaded Logger Class
772(4)
Thread Pools
776(1)
Threading Design and Best Practices
777(1)
Summary
778(3)
PART V C++ SOFTWARE ENGINEERING
Chapter 24 Maximizing Software Engineering Methods
781(20)
The Need for Process
782(1)
Software Life Cycle Models
783(1)
The Stagewise Model and Waterfall Model
783(1)
Benefits of the Waterfall Model
784(1)
Drawbacks of the Waterfall Model
785(1)
The Spiral Model
785(1)
Benefits of the Spiral Model
786(1)
Drawbacks of the Spiral Model
787(1)
The Rational Unified Process
787(1)
RUP as a Product
788(1)
RUP as a Process
788(1)
RUP in Practice
788(1)
Software Engineering Methodologies
789(1)
Agile
789(1)
Scrum
790(1)
Roles
790(1)
The Process
790(1)
Benefits of Scrum
791(1)
Drawbacks of Scrum
791(1)
Extreme Programming (XP)
792(1)
XP in Theory
792(3)
XP in Practice
795(1)
Software Triage
796(1)
Building Your Own Process and Methodology
796(1)
Be Open to New Ideas
796(1)
Bring New Ideas to the Table
797(1)
Recognize What Works and What Doesn't Work
797(1)
Don't Be a Renegade
797(1)
Source Code Control
797(2)
Summary
799(2)
Chapter 25 Writing Efficient C++
801(26)
Overview of Performance and Efficiency
802(1)
Two Approaches to Efficiency
802(1)
Two Kinds of Programs
802(1)
Is C++ an Inefficient Language?
802(1)
Language-Level Efficiency
803(1)
Handle Objects Efficiently
804(1)
Pass-by-Reference
804(1)
Return-by-Reference
805(1)
Catch Exceptions by Reference
806(1)
Use Move Semantics
806(1)
Avoid Creating Temporary Objects
806(2)
Use Inline Methods and Functions
808(1)
Design-Level Efficiency
808(1)
Cache Where Necessary
808(1)
Cache Invalidation
809(1)
Use Object Pools
809(1)
An Object Pool Implementation
810(2)
Using the Object Pool
812(1)
Profiling
813(1)
Profiling Example with gprof
814(1)
First Design Attempt
814(3)
Profile of the First Attempt
817(2)
Second Attempt
819(2)
Profile of the Second Attempt
821(1)
Profiling Example with Visual C++ 2013
822(1)
Profile of the First Design Attempt
822(3)
Summary
825(2)
Chapter 26 Conquering Debugging
827(36)
The Fundamental Law of Debugging
828(1)
Bug Taxonomies
828(1)
Avoiding Bugs
828(1)
Planning for Bugs
829(1)
Error Logging
829(2)
Debug Traces
831(1)
Debug Mode
831(4)
Ring Buffers
835(4)
Assertions
839(1)
Static Assertions
840(1)
Crash Dumps
841(1)
Debugging Techniques
842(1)
Reproducing Bugs
842(1)
Debugging Reproducible Bugs
843(1)
Debugging Nonreproducible Bugs
843(1)
Debugging Regressions
844(1)
Debugging Memory Problems
844(1)
Categories of Memory Errors
845(3)
Tips for Debugging Memory Errors
848(1)
Debugging Multithreaded Programs
849(1)
Debugging Example: Article Citations
850(1)
Buggy Implementation of an ArticleCitations Class
850(2)
Testing the ArticleCitations class
852(9)
Lessons from the ArticleCitations Example
861(1)
Summary
861(2)
APPENDIX A C++ INTERVIEWS
863(22)
Chapter 1 A Crash Course in C++ and the STL
863(1)
Chapters 2 and 18: Strings, Localization, and Regular Expressions
864(1)
Chapter 3 Coding with Style
865(1)
Chapter 4 Designing Professional C++ Programs
866(2)
Chapter 5 Designing with Objects
868(1)
Chapter 6 Designing for Reuse
868(1)
Chapters 7 and 8 Classes and Objects
869(3)
Chapter 9 Discovering Inheritance Techniques
872(1)
Chapter 10 C++ Quirks, Oddities, and Incidentals
873(2)
Chapters 11 and 21 Templates
875(1)
Chapter 12 Demystifying C++ I/O
875(1)
Chapter 13 Handling Errors
876(1)
Chapter 14 Overloading C++ Operators
877(1)
Chapters 15, 16, 17, and 20 The Standard Template Library
878(1)
Chapter 19 Additional Library Utilities
878(1)
Chapter 22 Memory Management
879(1)
Chapter 23 Multithreaded Programming with C++
880(1)
Chapter 24 Maximizing Software Engineering Methods
881(1)
Chapter 25 Writing Efficient C++
882(1)
Chapter 26 Conquering Debugging
882(3)
APPENDIX B ANNOTATED BIBLIOGRAPHY
885(10)
C++
885(4)
Beginning C++
885(1)
General C++
886(1)
I/O Streams and Strings
887(1)
The C++ Standard Library
887(1)
C++ Templates
888(1)
C++11/C++14
888(1)
C
889(1)
Unified Modeling Language, Uml
889(1)
Algorithms and Data Structures
890(1)
Random Numbers
890(1)
Open-Source Software
890(1)
Software Engineering Methodology
891(1)
Programming Style
892(1)
Computer Architecture
892(1)
Efficiency
893(1)
Testing
893(1)
Debugging
893(1)
Design Patterns
893(1)
Operating Systems
894(1)
Multithreaded Programming
894(1)
APPENDIX C STANDARD LIBRARY HEADER FILES
895(8)
The C Standard Library
895(2)
Containers
897(1)
Algorithms, Iterators, and Allocators
898(1)
General Utilities
898(1)
Mathematical Utilities
899(1)
Exceptions
899(1)
I/O Streams
900(1)
Threading Library
901(2)
Index 903
Marc Gregoire is a software engineer and developer of C/C++ applications for both Windows and Linux. He is a Microsoft Visual C++ MVP, the founder of the Belgian C++ users group, and is currently working on 3D laser scanning software for Nikon Metrology. He previously worked on critical 2G and 3G telecom software for Siemens and Nokia Siemens Networks. Marc maintains a blog at nuonsoft.com/blog. Wrox Professional guides are planned and written by working programmers to meet the real-world needs of programmers, developers, and IT professionals. Focused and relevant, they address the issues technology professionals face every day. They provide examples, practical solutions, and expert education in new technologies, all designed to help programmers do a better job.