توضیحاتی در مورد کتاب :
با یادگیری همه مفاهیم کلیدی C و کار کردن روی تمرینهای جالب، در C متخصص شوید. زبان C یکی از پرکاربردترین زبان های برنامه نویسی است و در حوزه های مختلفی از بازی گرفته تا برنامه نویسی رابط کاربری گرافیکی (GUI) و حتی سیستم عامل ها کاربرد دارد. اگر به دنبال گسترش فرصت های شغلی خود هستید، تسلط بر ویژگی های پیشرفته C کلیدی است. این کتاب با مفاهیم پیشرفته C شروع می شود و به شما کمک می کند تا سیستم پیچیده نوع C را رمزگشایی کنید و درک کنید که چگونه مراحل مختلف کامپایل کد منبع را به کد شی تبدیل می کند. سپس یاد خواهید گرفت که چگونه ابزارهایی را که برای کنترل جریان اجرا، گرفتن داده ها و انتقال داده ها باید مورد استفاده قرار گیرند، تشخیص دهید. با ایجاد مدلهای کوچک، حتی نحوه استفاده از لامبداها و عکسهای پیشرفته و بیان الگوهای طراحی API رایج در C را کشف خواهید کرد. همانطور که فصلهای بعدی را پوشش میدهید، راههایی را برای بهینهسازی کد خود با یادگیری در مورد تراز حافظه، دسترسی به حافظه پنهان و مدت زمانی که یک برنامه طول میکشد برای اجرا کشف خواهید کرد. فصل پایانی به شما کمک میکند تا با درک پیشبینی شاخههای CPU مدرن و چگونگی ایجاد سازگاری با حافظه پنهان کد، عملکرد را به حداکثر برسانید. در پایان این کتاب، شما مهارت های برنامه نویسی را توسعه خواهید داد که شما را از دیگر برنامه نویسان C متمایز می کند. آنچه یاد خواهید گرفت به آناتومی و گردش کار C بپردازید مزایا و معایب رویکردهای مختلف کدنویسی را در C مطالعه کنید، برنامه های خود را اجرا کنید و اشکال زدایی کنید فایل های شی را به عنوان یک کتابخانه پویا پیوند دهید از قالب ها، SFINAE، Constexpr if عبارات و قالب های متنوع استفاده کنید. بهترین روش را برای مدیریت منابع به کار ببرید این کتاب برای چه کسی است اگر در زبان C کار کرده اید اما می خواهید یاد بگیرید که چگونه از این زبان بهترین استفاده را ببرید، به خصوص برای پروژه های بزرگ، این کتاب برای شما مناسب است. درک کلی از برنامه نویسی و دانش استفاده از ویرایشگر برای تولید فایل های کد در فهرست های پروژه ضروری است. مقداری تجربه با زبانهای تایپ شده قوی، مانند C و C نیز توصیه میشود.
فهرست مطالب :
Cover
FM
Copyright
Table of Contents
Preface
Chapter 1: Anatomy of Portable C++ Software
Introduction
Managing C++ Projects
The Code-Build-Test-Run Loop
Building a CMake Project
Exercise 1: Using CMake to Generate Ninja Build Files
Importing a CMake Project into Eclipse CDT
Exercise 2: Importing the CMake File into Eclipse CDT
Exercise 3: Adding New Source Files to CMake and Eclipse CDT
Activity 1: Adding a New Source-Header File Pair to the Project
Unit Testing
Preparing for the Unit Tests
Exercise 4: Preparing Our Project for Unit Testing
Building, Running, and Writing Unit Tests
Exercise 5: Building and Running Tests
Exercise 6: Testing the Functionality of Code
Activity 2: Adding a New Class and Its Test
Understanding Compilation, Linking, and Object File Contents
Compilation and Linking Steps
Exercise 7: Identifying Build Steps
The Linking Step
Diving Deeper: Viewing Object Files
Exercise 8: Exploring Compiled Code
Debugging C++ Code
Exercise 9: Debugging with Eclipse CDT
Writing Readable Code
Indentation and Formatting
Use Meaningful Names as Identifiers
Keeping Algorithms Clear and Simple
Exercise 10: Making Code Readable
Activity 3: Making Code More Readable
Summary
Chapter 2A: No Ducks Allowed – Types and Deduction
Introduction
C++ Types
C++ Fundamental Types
C++ Literals
Specifying Types – Variables
Exercise 1: Declaring Variables and Exploring Sizes
Specifying Types – Functions
Exercise 2: Declaring Functions
Pointer Types
Exercise 3: Declaring and Using Pointers
Creating User Types
Enumerations
Exercise 4: Enumerations – Old and New School
Structures and Classes
Fraction Class
Constructors, Initialization, and Destructors
Class Special Member Functions
Implicit Versus Explicit Constructors
Class Special Member Functions – Compiler Generation Rules
Defaulting and Deleting Special Member Functions
Rule of Three/Five and Rule of Zero
Constructors – Initializing the Object
Exercise 5: Declaring and Initializing Fractions
Values Versus References and Const
Exercise 6: Declaring and Using Reference Types
Implementing Standard Operators
Implementing the Output Stream Operator (<<)
Structuring Our Code
Exercise 7: Adding Operators to the Fraction Class
Function Overloading
Classes, Structs, and Unions
Activity 1: Graphics Processing
Summary
Chapter 2B: No Ducks Allowed – Templates and Deduction
Introduction
Inheritance, Polymorphism, and Interfaces
Inheritance and Access Specifiers
Abstract Classes and Interfaces
Exercise 1: Implementing Game Characters with Polymorphism
Classes, Structs, and Unions Revisited
Visibility, Lifetime, and Access
Namespaces
Templates – Generic Programming
What is Generic Programming?
Introducing C++ Templates
C++ Pre-Packaged Templates
Type Aliases – typedef and using
Exercise 2: Implementing Aliases
Templates – More than Generic Programming
Substitution Failure Is Not An Error – SFINAE
Floating-Point Representations
Constexpr if Expressions
Non-Type Template Arguments
Exercise 3: Implementing Stringify – specialization Versus constexpr
Function Overloading Revisited
Template Type Deduction
Displaying the Deduced Types
Template Type Deduction – the Details
SFINAE Expression and Trailing Return Types
Class Templates
Exercise 4: Writing a Class Template
Activity 1: Developing a Generic "contains" Template Function
Summary
Chapter 3: No Leaks Allowed - Exceptions and Resources
Introduction
Variable Scope and Lifetime
Exceptions in C++
The Need for Exceptions
Stack Unwinding
Exercise 1: Implementing exceptions in Fraction and Stack
What Happens When an Exception is Thrown?
Throw-by-Value or Throw-by-Pointer
Standard Library Exceptions
Catching Exceptions
Exercise 2: Implementing Exception Handlers
CMake Generator Expressions
Exception Usage Guidelines
Resource Management (in an Exceptional World)
Resource Acquisition Is Initialization
Exercise 3: Implementing RAII for Memory and File Handles
Special Coding Techniques
C++ doesn't Need finally
RAII and the STL
Who Owns This Object?
Temporary Objects
Move Semantics
Implementing a Smart Pointer
STL Smart Pointers
std::unique_ptr
std::shared_ptr
std::weak_ptr
Smart Pointers and Calling Functions
Exercise 4: Implementing RAII with STL Smart Pointers
Rule of Zero/Five – A Different Perspective
Activity 1: Implementing Graphics Processing with RAII and Move
When is a Function Called?
Which Function to Call
Identifiers
Names
Name lookup
Argument-Dependent Lookup
Caveat Emptor
Exercise 5: Implementing Templates to Prevent ADL Issues
Implicit Conversion
Explicit – Preventing Implicit Conversion
Contextual Conversion
Exercise 6: Implicit and Explicit Conversions
Activity 2: Implementing classes for Date Calculations
Summary
Chapter 4: Separation of Concerns - Software Architecture, Functions, and Variadic Templates
Introduction
The Pointer to Implementation (PIMPL) Idiom
Logical and Physical Dependencies
The Pointer to Implementation (PIMPL) Idiom
Advantages and Disadvantages of PIMPL
Implementing PIMPL with unique_ptr<>
unique_ptr<> PIMPL Special Functions
Exercise 1: Implementing a Kitchen with unique_ptr<>
Function Objects and Lambda Expressions
Function Pointers
What is a Function Object?
Exercise 2: Implementing function objects
std::function<> template
Exercise 3: Implementing callbacks with std::function
What is a Lambda Expression?
Capturing data into Lambdas
Exercise 4: Implementing Lambdas
Variadic Templates
Activity 1: Implement a multicast event handler
Summary
Chapter 5: The Philosophers' Dinner – Threads and Concurrency
Introduction
Synchronous, Asynchronous, and Threaded Execution
Concurrency
Parallelism
Synchronous Execution
Asynchronous Execution
Exercise 1: Creating Threads in a Different Way
Review Synchronization, Data Hazards, and Race Conditions
Exercise 2: Writing an Example of Race Conditions
Data Hazards
RAW Dependency
WAR Dependency
WAW Dependency
Resource Synchronization
Event Synchronization
Deadlock
Move Semantics for Multithreading Closures
Exercise 3: Moving Objects to a Thread Function
Exercise 4: Creating and Working with an STL Container of Threads
Futures, Promises, and Async
Exercise 5: Synchronization with Future Results
Activity 1: Creating a Simulator to Model the Work of the Art Gallery
Summary
Chapter 6: Streams and I/O
Introduction
Reviewing the I/O Portion of the Standard Library
Predefined Standard Stream Objects
Exercise 1: Overriding the Left Shift Operator, <<, for User-Defined Types
File I/O Implementation Classes
Exercise 2: Reading and Writing User-Defined Data Types to a File
String I/O Implementation
Exercise 3: Creating a Function for Replacement Words in a String
I/O Manipulators
I/O Manipulators for Changing the Numeric Base of the Stream
Exercise 4: Displaying Entered Numbers in Different Numeric Bases
I/O Manipulators for Floating-Point Formatting
Exercise 5: Displaying Entered Floating-Point Numbers with Different Formatting
I/O Manipulators for Boolean Formatting
I/O Manipulators for Field Width and Fill Control
I/O Manipulators for Other Numeric Formatting
I/O Manipulators for Whitespace Processing
Making Additional Streams
How to Make an Additional Stream – Composition
Exercise 6: Composing the Standard Stream Object in the User-Defined Class
How to Make an Additional Stream – Inheritance
Exercise 7: Inheriting the Standard Stream Object
Leveraging Asynchronous I/O
Asynchronous I/O on Windows Platforms
Asynchronous I/O on Linux Platforms
Exercise 8: Asynchronously Reading from a File in Linux
Asynchronous Cross-Platform I/O Libraries
Interaction of Threads and I/O
Exercise 9: Developing a Thread-Safe Wrapper for std::cout
Using Macros
Activity 1: The Logging System for The Art Gallery Simulator
Summary
Chapter 7: Everybody Falls, It's How You Get Back Up – Testing and Debugging
Introduction
Assertions
Exercise 1: Writing and Testing Our First Assertion
Static Assertions
Exercise 2: Testing Static Assertions
Understanding Exception Handling
Exercise 3: Performing Exception Handling
Unit Testing and Mock Testing
Exercise 4: Creating Our First Unit Test Case
Unit Testing Using Mock Objects
Exercise 5: Creating Mock Objects
Breakpoints, Watchpoints, and Data Visualization
Working with the Stack Data Structure
Activity 1: Checking the Accuracy of the Functions Using Test Cases and Understanding Test-Driven Development (TDD)
Summary
Chapter 8: Need for Speed – Performance and Optimization
Introduction
Performance Measurement
Manual Estimation
Studying Generated Assembly Code
Manual Execution Timing
Exercise 1: Timing a Program's Execution
Timing Programs without Side Effects
Source Code Instrumentation
Exercise 2: Writing a Code Timer Class
Runtime Profiling
Exercise 3: Using perf to Profile Programs
Optimization Strategies
Compiler-Based Optimization
Loop Unrolling
Exercise 4: Using Loop Unrolling Optimizations
Profile Guided Optimization
Exercise 5: Using Profile Guided Optimization
Parallelization
Exercise 6: Using Compiler Parallelization
Source Code Micro Optimizations
Using the std::vector Container Efficiently
Exercise 7: Optimizing Vector Growth
Short-Circuit Logical Operators
Exercise 8: Optimizing Logical Operators
Branch Prediction
Exercise 9: Optimization for Branch Prediction
Further Optimizations
Cache Friendly Code
Exercise 10: Exploring the Effect of Caches on Data Structures
Exercise 11: Measuring the Impact of Memory Access
Caching
Prefetching
Effects of Caching on Algorithms
Optimizing for Cache-Friendliness
Exercise 12: Exploring the Cost of Heap Allocations
Struct of Arrays Pattern
Exercise 13: Using the Struct of Arrays Pattern
Algorithmic Optimizations
Exercise 14: Optimizing a Word Count Program
Activity 1: Optimizing a Spell Check Algorithm
Summary
Appendix
Index
توضیحاتی در مورد کتاب به زبان اصلی :
Become an expert at C++ by learning all the key C++ concepts and working through interesting exercises Key Features Explore C++ concepts through descriptive graphics and interactive exercises Learn how to keep your development bug-free with testing and debugging Discover various techniques to optimize your code Book Description C++ is one of the most widely used programming languages and is applied in a variety of domains, right from gaming to graphical user interface (GUI) programming and even operating systems. If you're looking to expand your career opportunities, mastering the advanced features of C++ is key. The book begins with advanced C++ concepts by helping you decipher the sophisticated C++ type system and understand how various stages of compilation convert source code to object code. You'll then learn how to recognize the tools that need to be used in order to control the flow of execution, capture data, and pass data around. By creating small models, you'll even discover how to use advanced lambdas and captures and express common API design patterns in C++. As you cover later chapters, you'll explore ways to optimize your code by learning about memory alignment, cache access, and the time a program takes to run. The concluding chapter will help you to maximize performance by understanding modern CPU branch prediction and how to make your code cache-friendly. By the end of this book, you'll have developed programming skills that will set you apart from other C++ programmers. What you will learn Delve into the anatomy and workflow of C++ Study the pros and cons of different approaches to coding in C++ Test, run, and debug your programs Link object files as a dynamic library Use templates, SFINAE, constexpr if expressions and variadic templates Apply best practice to resource management Who this book is for If you have worked in C++ but want to learn how to make the most of this language, especially for large projects, this book is for you. A general understanding of programming and knowledge of using an editor to produce code files in project directories is a must. Some experience with strongly typed languages, such as C and C++, is also recommended.