Professional C++, Third Edition
Buy Rights Online Buy Rights

Rights Contact Login For More Details

More About This Title Professional C++, Third Edition

English

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++.

English

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.

English

INTRODUCTION xli

Part I: INTRODUCTION TO PROFESSIONAL C++

CHAPTER 1: A CRA SH COURSE IN C++ AND THE STL 3

The Basics of C++ 4

Diving Deeper into C++ 25

C++ as an Object-Oriented Language 34

Summary 46

CHAPTER 2: WORKING WITH STRINGS 47

Dynamic Strings 47

Summary 55

CHAPTER 3: CODING WITH STYLE 57

Naming 68

Formatting 72

Summary 75

Part II: PROFESSIONAL C++ SOFTWAR E DESIGN

CHAPTER 4: DESIGNING PROFESSIONAL C++ PROGRA MS 79

What Is Programming Design? 80

The Importance of Programming Design 80

Designing for C++ 82

Two Rules for C++ Design 83

Reusing Code 87

Deciding Whether or Not to Use the STL 98

Designing with Patterns and Techniques 98

Designing a Chess Program 99

Summary 105

CHAPTER 5: DESIGNING WITH OBJECTS 107

Am I Thinking Procedurally? 108

The Object-Oriented Philosophy 108

Living in a World of Objects 111

Abstraction 122

Summary 126

CHAPTER 6: DESIGNING FOR REUSE 127

The Reuse Philosophy 127

How to Design Reusable Code 128

Summary 140

Part III: CODING THE PROFESSIONAL WAY

CHAPTER 7: GAINING PROFICIENCY WITH CLASSES AND OBJECTS 143

Introducing the Spreadsheet Example 144

Writing Classes 144

Summary 175

CHAPTER 8: MASTERING CLASSES AND OBJECTS 177

Dynamic Memory Allocation in Objects 178

Different Kinds of Data Members 188

More about Methods 193

Nested Classes 199

Enumerated Types Inside Classes 201

Friends 202

Operator Overloading 203

Summary 215

CHAPTER 9: DISCOVERING INHERITANCE TECHNIQUES 217

Building Classes with Inheritance 218

Multiple Inheritance 244

Interesting and Obscure Inheritance Issues 249

Summary 271

CHAPTER 10: C++ QUIRKS, ODDITIES, AND INCIDENTALS 273

References 274

Types and Casts 295

Summary of Casts 301

Scope Resolution 302

C++11 / C++14 303

Header Files 309

C Utilities 310

Summary 313

CHAPTER 11: WRITING GENERIC CODE WITH TEMPLATES 315

Overview of Templates 316

Class Templates 317

Function Templates 339

Variable Templates 343

Summary 343

CHAPTER 12: DEMYSTIFYING C++ I/O 345

Using Streams 346

String Streams 360

File Streams 362

Bidirectional I/O 366

Summary 367

CHAPTER 13: HANDLING ERR ORS 369

Errors and Exceptions 370

Exception Mechanics 372

Exceptions and Polymorphism 387

Stack Unwinding and Cleanup 394

Common Error-Handling Issues 397

Putting It All Together 405

Summary 409

CHAPTER 14: OVERLOADING C++ OPERA TORS 411

Overview of Operator Overloading 412

Overloading the Arithmetic Operators 420

Overloading the Bitwise and Binary Logical Operators 421

Overloading the Insertion and Extraction Operators 422

Overloading the Subscripting Operator 423

Overloading the Function Call Operator 428

Overloading the Dereferencing Operators 429

Writing Conversion Operators 432

Overloading the Memory Allocation and Deallocation Operators 436

Summary 442

CHAPTER 15: OVERVIEW OF THE C++ STANDARD LIBRARY 443

Coding Principles 444

Overview of the C++ Standard Library 445

Summary 465

CHAPTER 16: UNDERSTANDING CONTAINERS AND ITERATORS 467

Containers Overview 468

Sequential Containers 473

Container Adapters 498

Associative Containers 504

Unordered Associative Containers/Hash Tables 516

Other Containers 523

Summary 529

CHAPTER 17: MASTERING STL ALGORITHMS 531

Overview of Algorithms 532

Lambda Expressions 536

Function Objects 542

Algorithm Details 550

Algorithms Example: Auditing Voter Registrations 570

Summary 573

CHAPTER 18: STRING LOCALIZATION AND REGULAR EXPRESSIONS 575

Localization 575

Regular Expressions 581

ECMAScript Syntax 582

Summary 599

CHAPTER 19: ADDITIONAL LIBRARY UTILITIES 601

std::function 601

Ratios 603

The Chrono Library 606

Random Number Generation 612

Tuples 621

Summary 624

Part IV: MASTERING ADVANCED FEATURES OF C++

CHAPTER 20: CUSTOMIZING AND EXTENDING THE STL 627

Allocators 628

Iterator Adapters 628

Extending the STL 634

Summary 671

CHAPTER 21: ADVANCED TEMPLATES 673

More about Template Parameters 673

Class Template Partial Specialization 679

Emulating Function Partial Specialization with Overloading 683

Template Recursion 685

Type Inference 689

Variadic Templates 691

Metaprogramming 695

Summary 705

CHAPTER 22: MEMORY MANAGEMENT 707

Working with Dynamic Memory 708

Array-Pointer Duality 720

Low-Level Memory Operations 722

Smart Pointers 727

Common Memory Pitfalls 734

Summary 740

CHAPTER 23: MULTITHREADED PROGRAMMING WITH C++ 741

Introduction 742

Threads 746

Atomic Operations Library 755

Mutual Exclusion 758

Condition Variables 767

Futures 770

Example: Multithreaded Logger Class 772

Thread Pools 776

Threading Design and Best Practices 777

Summary 778

Part V: C++ SOFTWAR E ENGINEERING

CHAPTER 24: MAXIMIZING SOFTWARE ENGINEERING METHODS 781

The Need for Process 782

Software Life Cycle Models 783

Software Engineering Methodologies 789

Building Your Own Process and Methodology 796

Source Code Control 797

Summary 799

CHAPTER 25: WRITING EFFICIENT C++ 801

Overview of Performance and Efficiency 802

Language-Level Efficiency 803

Design-Level Efficiency 808

Profiling 813

Summary 825

CHAPTER 26: CONQUERING DEBUGGING 827

The Fundamental Law of Debugging 828

Bug Taxonomies 828

Avoiding Bugs 828

Planning for Bugs 829

Debugging Techniques 842

Summary 861

APPENDIX A: C++ INTERVIEWS 863

Chapter 1: A Crash Course in C++ and the STL 863

Chapters 2 and 18: Strings, Localization, and Regular Expressions 864

Chapter 3: Coding with Style 865

Chapter 4: Designing Professional C++ Programs 866

Chapter 5: Designing with Objects 868

Chapter 6: Designing for Reuse 868

Chapters 7 and 8: Classes and Objects 869

Chapter 9: Discovering Inheritance Techniques 872

Chapter 10: C++ Quirks, Oddities, and Incidentals 873

Chapters 11 and 21: Templates 875

Chapter 12: Demystifying C++ I/O 875

Chapter 13: Handling Errors 876

Chapter 14: Overloading C++ Operators 877

Chapters 15, 16, 17, and 20: The Standard Template Library 878

Chapter 19: Additional Library Utilities 878

Chapter 22: Memory Management 879

Chapter 23: Multithreaded Programming with C++ 880

Chapter 24: Maximizing Software Engineering Methods 881

Chapter 25: Writing Efficient C++ 882

Chapter 26: Conquering Debugging 882

APPENDIX B: ANNOTATED BIBLIOGRAPHY 885

C++ 885

C 889

Unified Modeling Language, Uml 889

Algorithms and Data Structures 890

Random Numbers 890

Open-Source Software 890

Software Engineering Methodology 891

Programming Style 892

Computer Architecture 892

Efficiency 893

Testing 893

Debugging 893

Design Patterns 893

Operating Systems 894

Multithreaded Programming 894

APPENDIX C: STANDARD LIBRARY HEADER FILES 895

The C Standard Library 895

Containers 897

Algorithms, Iterators, and Allocators 898

General Utilities 898

Mathematical Utilities 899

Exceptions 899

I/O Streams 900

Threading Library 901

INDEX 903

loading