You are previewing C++ Recipes: A Problem-Solution Approach.
O'Reilly logo
C++ Recipes: A Problem-Solution Approach

Book Description

C++ Recipes: A Problem-Solution Approach is Apress' solution for those C++ programmers looking for a handy code cookbook reference guide. It covers the latest C++ 14 as well as some of the code templates available in the latest Standard Template Library (STL).

In this handy reference, you'll find numbers, strings, dates, times, classes, exceptions, streams, flows, pointers and more. Also, you'll see various code samples, templates for C++ algorithms, parallel processing, multithreading and numerical processes. These have many applications including game development, big data analytics, financial engineering and analysis, enterprise applications and more. A wealth of STL templates on function objects, adapters, allocators, and extensions are also available.

This is a "must have", contemporary reference for your technical books library.

Table of Contents

  1. Cover
  2. Title
  3. Copyright
  4. Contents at a Glance
  5. Contents
  6. About the Author
  7. About the Technical Reviewers
  8. Acknowledgments
  9. Introduction
  10. Chapter 1: Beginning C++
    1. Recipe 1-1. Finding a Text Editor
      1. Problem
      2. Solution
    2. Recipe 1-2. Installing Clang on Ubuntu
      1. Problem
      2. Solution
      3. How It Works
    3. Recipe 1-3. Installing Clang on Windows
      1. Problem
      2. Solution
      3. How It Works
    4. Recipe 1-4. Installing Clang on OS X
      1. Problem
      2. Solution
      3. How It Works
    5. Recipe 1-5. Building Your First C++ Program
      1. Problem
      2. Solution
    6. Recipe 1-6. Debugging C++ programs using GDB in Cygwin or Linux
      1. Problem
      2. Solution
      3. How It Works
    7. Recipe 1-7. Debugging Your C++ Programs on OS X
      1. Problem
      2. Solution
      3. How It Works
    8. Recipe 1-8. Switching C++ Compilation Modes
      1. Problem
      2. Solution
      3. How It Works
    9. Recipe 1-9. Building with the Boost Library
      1. Problem
      2. Solution
      3. How It Works
  11. Chapter 2: Modern C++
    1. Recipe 2-1. Initializing Variables
      1. Problem
      2. Solution
      3. How It Works
    2. Recipe 2-2. Initializing Objects with Initializer Lists
      1. Problem
      2. Solution
      3. How It Works
    3. Recipe 2-3. Using Type Deduction
      1. Problem
      2. Solution
      3. How It Works
    4. Recipe 2-4. Using auto with Functions
      1. Problem
      2. Solution
      3. How It Works
    5. Recipe 2-5. Working with Compile Time Constants
      1. Problem
      2. Solution
      3. How It Works
    6. Recipe 2-6. Working with Lambdas
      1. Problem
      2. Solution
      3. How It Works
    7. Recipe 2-7. Working with Time
      1. Problem
      2. Solution
      3. How It Works
    8. Recipe 2-8. Understanding lvalue and rvalue References
      1. Problem
      2. Solution
      3. How It Works
    9. Recipe 2-9. Using Managed Pointers
      1. Problem
      2. Solution
      3. How It Works
  12. Chapter 3: Working with Text
    1. Recipe 3-1. Representing Strings in Code Using Literals
      1. Problem
      2. Solution
      3. How It Works
    2. Recipe 3-2. Localizing User Facing Text
      1. Problem
      2. Solution
      3. How It Works
    3. Recipe 3-3. Reading Strings from a File
      1. Problem
      2. Solution
      3. How It Works
    4. Recipe 3-4. Reading the Data from an XML File
      1. Problem
      2. Solution
      3. How It Works
    5. Recipe 3-5. Inserting Runtime Data into Strings
      1. Problem
      2. Solution
      3. How It Works
  13. Chapter 4: Working with Numbers
    1. Recipe 4-1. Using the Integer Types in C++
      1. Problem
      2. Solution
      3. How It Works
    2. Recipe 4-2. Making Decisions with Relational Operators
      1. Problem
      2. Solution
      3. How It Works
    3. Recipe 4-3. Chaining Decisions with Logical Operators
      1. Problem
      2. Solution
      3. How It Works
    4. Recipe 4-4. Using Hexadecimal Values
      1. Problem
      2. Solution
      3. How It Works
    5. Recipe 4-5. Bit Twiddling with Binary Operators
      1. Problem
      2. Solution
      3. How It Works
  14. Chapter 5: Classes
    1. Recipe 5-1. Defining a Class
      1. Problem
      2. Solution
      3. How It Works
    2. Recipe 5-2. Adding Data to a Class
      1. Problem
      2. Solution
      3. How It Works
    3. Recipe 5-3. Adding Methods
      1. Problem
      2. Solution
      3. How It Works
    4. Recipe 5-4. Using Access Modifiers
      1. Problem
      2. Solution
      3. How It Works
    5. Recipe 5-5. Initializing Class Member Variables
      1. Problem
      2. Solution
      3. How It Works
    6. Recipe 5-6. Cleaning Up Classes
      1. Problem
      2. Solution
      3. How It Works
    7. Recipe 5-7. Copying Classes
      1. Problem
      2. Solution
      3. How It Works
    8. Recipe 5-8. Optimizing Code with Move Semantics
      1. Problem
      2. Solution
      3. How It Works
  15. Chapter 6: Inheritance
    1. Recipe 6-1. Inheriting from a Class
      1. Problem
      2. Solution
      3. How It Works
    2. Recipe 6-2. Controlling Access to Member Variables and Methods in Derived Classes
      1. Problem
      2. Solution
      3. How It Works
    3. Recipe 6-3. Hiding Methods in Derived Classes
      1. Problem
      2. Solution
      3. How It Works
    4. Recipe 6-4. Using Polymorphic Base Classes
      1. Problem
      2. Solution
      3. How It Works
    5. Recipe 6-5. Preventing Method Overrides
      1. Problem
      2. Solution
      3. How It Works
    6. Recipe 6-6. Creating Interfaces
      1. Problem
      2. Solution
      3. How It Works
    7. Recipe 6-7. Multiple Inheritance
      1. Problem
      2. Solution
      3. How It Works
  16. Chapter 7: The STL Containers
    1. Recipe 7-1. Storing a Fixed Number of Objects
      1. Problem
      2. Solution
      3. How It Works
    2. Recipe 7-2. Storing a Growing Number of Objects
      1. Problem
      2. Solution
      3. How It Works
    3. Recipe 7-3. Storing a Set of Elements that Is Constantly Altered
      1. Problem
      2. Solution
      3. How It Works
    4. Recipe 7-4. Storing Sorted Objects in a Container that Enables Fast Lookups
      1. Problem
      2. Solution
      3. How It Works
    5. Recipe 7-5. Storing Unsorted Elements in a Container for Very Fast Lookups
      1. Problem
      2. Solution
      3. How It Works
  17. Chapter 8: The STL Algorithms
    1. Recipe 8-1. Using an iterator to Define a Sequence within a Container
      1. Problem
      2. Solution
      3. How It Works
    2. Recipe 8-2. Calling a Function on Every Element in a Container
      1. Problem
      2. Solution
      3. How It Works
    3. Recipe 8-3. Finding the Maximum and Minimum Values in a Container
      1. Problem
      2. Solution
      3. How It Works
    4. Recipe 8-4. Counting Instances of a Value in a Sequence
      1. Problem
      2. Solution
      3. How It Works
    5. Recipe 8-5. Finding Values in a Sequence
      1. Problem
      2. Solution
      3. How It Works
    6. Recipe 8-6. Sorting Elements in a Sequence
      1. Problem
      2. Solution
      3. How It Works
  18. Chapter 9: Templates
    1. 9-1. Creating a Template Function
      1. Problem
      2. Solution
      3. How It Works
    2. 9-2. Partially Specializing a Template
      1. Problem
      2. Solution
      3. How It Works
    3. 9-3. Creating Class Templates
      1. Problem
      2. Solution
      3. How It Works
    4. 9-4. Creating Singletons
      1. Problem
      2. Solution
      3. How It Works
    5. 9-5. Calculating Values at Compile Time
      1. Problem
      2. Solution
      3. How It Works
  19. Chapter 10: Memory
    1. 10-1. Using Static Memory
      1. Problem
      2. Solution
      3. How It Works
    2. 10-2. Using Stack Memory
      1. Problem
      2. Solution
      3. How It Works
    3. 10-3. Using Heap Memory
      1. Problem
      2. Solution
      3. How It Works
    4. 10-4. Using Automated Shared Memory
      1. Problem
      2. Solution
      3. How It Works
    5. 10-5. Creating Single-Instance Dynamic Objects
      1. Problem
      2. Solution
      3. How It Works
    6. 10-6. Creating Smart Pointers
      1. Problem
      2. Solution
      3. How It Works
    7. 10-7. Debugging Memory Problems by Overloading new and delete
      1. Problem
      2. Solution
      3. How It Works
    8. 10-8. Calculating Performance Impacts of Code Changes
      1. Problem
      2. Solution
      3. How It Works
    9. 10-9. Understanding the Performance Impacts of Memory Choices
      1. Problem
      2. Solution
      3. How It Works
    10. 10-10. Reducing Memory Fragmentation
      1. Problem
      2. Solution
      3. How It Works
  20. Chapter 11: Concurrency
    1. 11-1. Using Threads to Execute Concurrent Tasks
      1. Problem
      2. Solution
      3. How It Works
    2. 11-2. Creating thread Scope Variables
      1. Problem
      2. Solution
      3. How It Works
    3. 11-3. Accessing Shared Objects Using Mutual Exclusion
      1. Problem
      2. Solution
      3. How It Works
    4. 11-4. Creating Threads that Wait for Events
      1. Problem
      2. Solution
      3. How It Works
    5. 11-5. Retrieving Results from a Thread
      1. Problem
      2. Solution
      3. How It Works
    6. 11-6. Synchronizing Queued Messages between Threads
      1. Problem
      2. Solution
      3. How It Works
  21. Chapter 12: Networking
    1. 12-1. Setting Up a Berkeley Sockets Application on OS X
      1. Problem
      2. Solution
      3. How It Works
    2. 12-2. Setting Up a Berkeley Sockets Application in Eclipse on Ubuntu
      1. Problem
      2. Solution
      3. How It Works
    3. 12-3. Setting Up a Winsock 2 Application in Visual Studio on Windows
      1. Problem
      2. Solution
      3. How It Works
    4. 12-4. Creating a Socket Connection between Two Programs
      1. Problem
      2. Solution
      3. How It Works
    5. 12-5. Creating a Networking Protocol between Two Programs
      1. Problem
      2. Solution
      3. How It Works
  22. Chapter 13: Scripting
    1. 13-1. Creating a Lua Library Project in Visual Studio
      1. Problem
      2. Solution
      3. How It Works
    2. 13-2. Creating a Lua Library Project in Eclipse
      1. Problem
      2. Solution
      3. How It Works
    3. 13-3. Creating a Lua Project in Xcode
      1. Problem
      2. Solution
      3. How It Works
    4. 13-4. Using the Lua Programming Language
      1. Problem
      2. Solution
      3. How It Works
    5. 13-5. Calling Lua Functions from C++
      1. Problem
      2. Solution
      3. How It Works
    6. 13-6. Calling C Functions from Lua
      1. Problem
      2. Solution
      3. How It Works
    7. 13-7. Creating Asynchronous Lua Functions
      1. Problem
      2. Solution
      3. How It Works
  23. Chapter 14: 3D Graphics Programming
    1. 14-1. An Introduction to GLFW
      1. Problem
      2. Solution
      3. How It Works
    2. 14-2. Rendering a Triangle
      1. Problem
      2. Solution
      3. How It Works
    3. 14-3. Creating a Textured Quad
      1. Problem
      2. Solution
      3. How It Works
    4. 14-4. Loading Geometry from a File
      1. Problem
      2. Solution
      3. How It Works
  24. Index