O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

C++ Crash Course

Book Description

Upgrade your Code with C++

C++ is one of the most widely used languages for real-world software. In the hands of a knowledgeable programmer, C++ can produce small, efficient, and readable code that any programmer would be proud of.

Designed for intermediate to advanced programmers, C++ Crash Course cuts through the weeds to get you straight to the core of C++17, the most modern revision of the ISO standard. Part 1 covers the core of the C++ language, where you’ll learn about everything from types and functions, to the object life cycle and expressions. Part 2 introduces you to the C++ Standard Library and Boost Libraries, where you'll learn about all of the high-quality, fully-featured facilities available to you. You’ll cover special utility classes, data structures, and algorithms, and learn how to manipulate file systems and build high-performance programs that communicate over networks.

You'll learn all the major features of modern C++, including:

•Fundamental types, reference types, and user-defined types
•The object lifecycle including storage duration, memory management, exceptions, call stacks, and the RAII (resource acquisition is initialization) paradigm
•Compile-time polymorphism with templates and run-time polymorphism with virtual classes
•Advanced expressions, statements, and functions
•Smart pointers, data structures, dates and times, numerics, and probability/statistics facilities
•Containers, iterators, strings, and algorithms
•Streams and files, concurrency, networking, and application development

With well over 500 code samples and nearly 100 exercises, C++ Crash Course is sure to help you build a strong C++ foundation.

Covers C++17

Table of Contents

  1. Cover Page
  2. Title Page
  3. Copyright Page
  4. About the Author
  5. About the Technical Reviewer
  6. Brief Contents
  7. Contents in Detail
  8. FOREWORD by Peter Bindels
  9. ACKNOWLEDGMENTS
  10. INTRODUCTION
    1. About This Book
    2. Who Should Read This Book?
    3. What’s in This Book?
  11. AN OVERTURE TO C PROGRAMMERS
    1. Upgrading to Super C
    2. C++ Themes
    3. Relax and Enjoy Your Shoes
  12. PART I THE C++ CORE LANGUAGE
  13. 1 UP AND RUNNING
    1. The Structure of a Basic C++ Program
    2. The Compiler Tool Chain
    3. Bootstrapping C++
    4. Debugging
    5. Summary
  14. 2 TYPES
    1. Fundamental Types
    2. Arrays
    3. User-Defined Types
    4. Fully Featured C++ Classes
    5. Summary
  15. 3 REFERENCE TYPES
    1. Pointers
    2. References
    3. Usage of Pointers and References
    4. auto Type Deduction
    5. Summary
  16. 4 THE OBJECT LIFE CYCLE
    1. An Object’s Storage Duration
    2. Tracing the Object Life Cycle
    3. Exceptions
    4. A SimpleString Class
    5. Copy Semantics
    6. Move Semantics
    7. Summary
  17. 5 RUNTIME POLYMORPHISM
    1. Polymorphism
    2. A Motivating Example
    3. Defining Interfaces
    4. Updating the Bank Logger
    5. Summary
  18. 6 COMPILE-TIME POLYMORPHISM
    1. Templates
    2. Declaring Templates
    3. Named Conversion Functions
    4. mean: A Template Function Example
    5. SimpleUniquePointer: A Template Class Example
    6. Type Checking in Templates
    7. Concepts
    8. static_assert: The Preconcepts Stopgap
    9. Non-Type Template Parameters
    10. Variadic Templates
    11. Advanced Template Topics
    12. Template Source Code Organization
    13. Polymorphism at Runtime vs. Compile Time
    14. Summary
  19. 7 EXPRESSIONS
    1. Operators
    2. User-Defined Literals
    3. Type Conversions
    4. Constant Expressions
    5. Volatile Expressions
    6. Summary
  20. 8 STATEMENTS
    1. Expression Statements
    2. Compound Statements
    3. Declaration Statements
    4. Selection Statements
    5. Iteration Statements
    6. Jump Statements
    7. Summary
  21. 9 FUNCTIONS
    1. Function Declarations
    2. auto Return Types
    3. auto and Function Templates
    4. Overload Resolution
    5. Variadic Functions
    6. Variadic Templates
    7. Function Pointers
    8. The Function-Call Operator
    9. A Counting Example
    10. Lambda Expressions
    11. std::function
    12. The main Function and the Command Line
    13. Summary
  22. PART II C++ Libraries and Frameworks
  23. 10 TESTING
    1. Unit Tests
    2. An Extended Example: Taking a Brake
    3. Unit-Testing and Mocking Frameworks
    4. Mocking Frameworks
    5. Summary
  24. 11 SMART POINTERS
    1. Smart Pointers
    2. Smart Pointer Ownership
    3. Scoped Pointers
    4. Unique Pointers
    5. Shared Pointers
    6. Weak Pointers
    7. Intrusive Pointers
    8. Summary of Smart Pointer Options
    9. Allocators
    10. Summary
  25. 12 UTILITIES
    1. Data Structures
    2. Date and Time
    3. Numerics
    4. Summary
  26. 13 CONTAINERS
    1. Sequence Containers
    2. Associative Containers
    3. Graphs and Property Trees
    4. The Boost Graph Library
    5. Boost Property Trees
    6. Initializer Lists
    7. Summary
  27. 14 ITERATORS
    1. Iterator Categories
    2. Auxiliary Iterator Functions
    3. Additional Iterator Adapters
    4. Summary
  28. 15 STRINGS
    1. std::string
    2. String View
    3. Regular Expressions
    4. Boost String Algorithms
    5. Boost Tokenizer
    6. Localizations
    7. Summary
  29. 16 STREAMS
    1. Streams
    2. Summary
  30. 17 FILESYSTEMS
    1. Filesystem Concepts
    2. std::filesystem::path
    3. Files and Directories
    4. Directory Iterators
    5. fstream Interoperation
    6. Summary
  31. 18 ALGORITHMS
    1. Algorithmic Complexity
    2. Execution Policies
    3. Non-Modifying Sequence Operations
    4. Mutating Sequence Operations
    5. Sorting and Related Operations
    6. Binary Search
    7. Partitioning Algorithms
    8. Merging Algorithms
    9. Extreme-Value Algorithms
    10. Numeric Operations
    11. Boost Algorithm
  32. 19 CONCURRENCY AND PARALLELISM
    1. Concurrent Programming
    2. Parallel Algorithms
    3. Summary
  33. 20 NETWORK PROGRAMMING WITH BOOST ASIO
    1. The Boost Asio Programming Model
    2. Network Programming with Asio
    3. Multithreading Boost Asio
    4. Summary
  34. 21 WRITING APPLICATIONS
    1. Program Support
    2. Boost ProgramOptions
    3. Special Topics in Compilation
    4. Summary
  35. INDEX