C++ in One Hour a Day, Sams Teach Yourself

Paperback Engels 2022 9780137334681
Verwachte levertijd ongeveer 9 werkdagen

Samenvatting

Learn C++ programming at your own pace—Covers modern C++ 20

Starting with one hour a day, you can gain all the skills you need to begin programming in C++. This complete tutorial will help you quickly master the basics of object-oriented programming and teach you advanced C++ language features and concepts. Fully updated for the C++20 standard, this practical book is designed to help you write C++ code that's faster, simpler, and more reliable and master the fundamentals of C++ and object-oriented programming. No programming experience required: start writing well-organized, efficient C++ programs quickly! Apply proven Do's and Don'ts to leverage best practices and avoid pitfalls from day one Test your knowledge and expertise with focused exercises after every lesson Simplify your code using automatic type deduction and other features Accelerate learning using nearly 300 code samples explained within Preview improvements expected in C++23

Lessons

Part I - The Basics: Using Variables, Declaring Constants; Arrays and Strings; Expressions, Statements, and Operators; Controlling Program Flow; Functions; Pointers and References

Part II - Fundamentals of Object-Oriented C++ Programming: Classes and Objects; Implementing Inheritance; Polymorphism; Operator Types and Operator Overloading; Casting Operators; Macros and Templates

PART III - Learning the Standard Template Library (STL): The STL String Class; STL Dynamic Array Classes; STL list and forward_list; STL set and multiset; STL map and multimap

PART IV: Lambda Expressions and STL Algorithms: Function Objects; Lambda Expressions;

Specificaties

ISBN13:9780137334681
Taal:Engels
Bindwijze:Paperback

Lezersrecensies

Wees de eerste die een lezersrecensie schrijft!

Inhoudsopgave

<p>Introduction xxvi<br><strong>PART I: The Basics<br>Lesson 1:</strong> Getting Started <br>A Brief History of C++<br> Connection to C <br> Advantages of C++<br> Evolution of the C++ Standard<br> Who Uses Programs Written in C++?<br>Programming a C++ Application<br> Steps in Building an Executable <br> Analyzing Errors and Debugging<br> Integrated Development Environments <br> Programming Your First C++ Application<br> Building and Executing Your First C++ Application<br> Understanding Compiler Errors <br>What’s New in C++20?<br>Summary <br>Q&amp;A <br>Workshop <br> Quiz <br> Exercises <br><strong>Lesson 2:</strong> The Anatomy of a C++ Program <br>Parts of the Hello World Program<br>Preprocessor Directive #include<br>The Body of Your Program: main()<br> Returning a Value <br>The Concept of Namespaces <br>Comments in C++ Code<br>Functions in C++<br>Basic Input Using std::cin and Output Using std::cout<br>Summary <br>Q&amp;A<br>Workshop <br> Quiz <br> Exercises <br><strong>Lesson 3:</strong> Using Variables, Declaring Constants<br>What Is a Variable?<br> Memory and Addressing in Brief <br> Declaring Variables to Access and Use Memory<br> Declaring and Initializing Multiple Variables of a Type <br> Understanding the Scope of a Variable <br> Global Variables <br> Naming Conventions <br>Common Compiler-Supported C++ Variable Types<br> Using Type bool to Store Boolean Values <br> Using Type char to Store Character Values<br> The Concept of Signed and Unsigned Integers <br> Signed Integer Types short, int, long, and long long<br> Unsigned Integer Types unsigned short, unsigned int, unsigned long, and unsigned long long<br> Avoiding Overflow Errors by Selecting Correct Data Types <br> Floating-Point Types float and double<br>Determining the Size of a Variable by Using sizeof()<br> Avoid Narrowing Conversion Errors by Using List Initialization<br>Automatic Type Inference Using auto <br>Using typedef to Substitute a Variable’s Type <br>What Is a Constant?<br> Literal Constants <br> Declaring Variables as Constants Using const<br> Constant Expressions Using constexpr<br> C++20 Immediate Functions Using consteval <br> Enumerations<br> Scoped Enumerations <br> Defining Constants by Using #define<br>Keywords You Cannot Use as Variable or Constant Names<br>Summary<br>Q&amp;A<br>Workshop <br> Quiz <br> Exercises <br><strong>Lesson 4:</strong> Managing Arrays and Strings<br>What Is an Array?<br> The Need for Arrays <br> Declaring and Initializing Static Arrays <br> How Data Is Stored in an Array<br> Accessing Data Stored in an Array <br> Modifying Data Stored in an Array<br>Multidimensional Arrays <br> Declaring and Initializing Multidimensional Arrays <br> Accessing Elements in a Multidimensional Array<br>Dynamic Arrays <br>C-Style Character Strings<br>C++ Strings: Using std::string <br>Summary <br>Q&amp;A<br>Workshop <br> Quiz <br> Exercises <br><strong>Lesson 5:</strong> Working with Expressions, Statements, and Operators<br>Statements <br>Compound Statements, or Blocks <br>Using Operators <br> The Assignment Operator (=)<br> Understanding l-Values and r-Values<br> Operators to Add (+), Subtract (-), Multiply (*), Divide (/), and Modulo Divide (%) <br> Operators to Increment (++) and Decrement (--) <br> To Postfix or to Prefix? <br> Equality Operators (== and !=)<br> Relational Operators <br> C++20 Three-Way Comparison Operator (&lt;=&gt;) <br> Logical Operations NOT, AND, OR, and XOR<br> Using C++ Logical Operators NOT (!), AND (&amp;&amp;), and OR (||)<br> Bitwise NOT (~), AND (&amp;), OR (|), and XOR (^) Operators <br> Bitwise Right Shift (&gt;&gt;) and Left Shift (&lt;&lt;) Operators<br> Compound Assignment Operators <br> Using the sizeof() Operator to Determine the Memory Occupied by a Variable<br> Operator Precedence and Associativity <br>Summary <br>Q&amp;A<br>Workshop <br> Quiz <br> Exercises <br><strong>Lesson 6:</strong> Controlling Program Flow <br>Conditional Execution Using if.else<br> Conditional Programming Using if.else <br> Conditional Execution of Statements Within a Block <br> Nested if Statements <br> Conditional Processing Using switch-case <br> Conditional Execution Using the ?: Operator <br>Getting Code to Execute in Loops <br> A Rudimentary Loop Using goto <br> The while Loop<br> The do.while Loop <br> The for Loop <br> The Range-Based for Loop <br>Modifying Loop Behavior Using continue and break <br> Loops That Don’t End: Infinite Loops <br> Controlling Infinite Loops <br>Programming Nested Loops <br> Using Nested Loops to Walk a Multidimensional Array <br> Using Nested Loops to Calculate Fibonacci Numbers<br>Summary <br>Q&amp;A <br>Workshop <br> Quiz <br> Exercises <br><strong>Lesson 7:</strong> Organizing Code with Functions <br>The Need for Functions <br> What Is a Function Prototype? <br> What Is a Function Definition? <br> What Is a Function Call, and What Are Arguments? <br> Programming a Function with Multiple Parameters <br> Programming Functions with No Parameters or No Return Values <br> Function Parameters with Default Values <br> Recursion: Functions That Invoke Themselves <br> Functions with Multiple Return Statements <br>Using Functions to Work with Different Forms of Data<br> Overloading Functions <br> Passing an Array of Values to a Function <br> Passing Arguments by Reference <br>How Function Calls Are Handled by the Microprocessor<br> Inline Functions <br> Automatic Return Type Deduction <br> Lambda Functions <br>Summary <br>Q&amp;A <br>Workshop <br> Quiz <br> Exercises <br><strong>Lesson 8:</strong> Pointers and References Explained<br>What Is a Pointer?<br> Declaring a Pointer <br> Determining the Address of a Variable by Using the Reference Operator (&amp;) <br> Using Pointers to Store Addresses <br> Accessing Pointed Data Using the Dereference Operator (*) <br> What Is the Size of a Pointer?<br>Dynamic Memory Allocation <br> Using the Operators new and delete to Allocate and Release<br> Memory Dynamically <br> Effects of the Increment (++) and Decrement (--) Operators on Pointers <br> Using the const Keyword on Pointers<br> Passing Pointers to Functions <br> Similarities Between Arrays and Pointers <br>Common Programming Mistakes When Using Pointers <br> Memory Leaks <br> Pointers Pointing to Invalid Memory Locations <br> Dangling Pointers (Also Called Stray or Wild Pointers) <br> Checking Whether an Allocation Request Using new Succeeded<br>Pointer Programming Best Practices <br>What Is a Reference? <br> What Makes References Useful? <br> Using the Keyword const on References <br> Passing Arguments by Reference to Functions <br>Summary <br>Q&amp;A <br>Workshop <br> Quiz <br> Exercises <br><strong>PART II: Fundamentals of Object-Oriented C++ Programming<br>Lesson 9:</strong> Classes and Objects <br>The Concept of Classes and Objects <br> Declaring a Class <br> An Object as an Instance of a Class<br> Accessing Members by Using the Dot Operator (.) <br> Accessing Members by Using the Pointer Operator (-&gt;) <br>The Keywords public and private <br> Abstraction of Data via the Keyword private <br>Constructors <br> Declaring and Implementing a Constructor <br> When and How to Use Constructors <br> Overloading Constructors <br> A Class Without a Default Constructor <br> Constructor Parameters with Default Values <br> Constructors with Initialization Lists<br>Destructor <br> Declaring and Implementing a Destructor<br> When and How to Use a Destructor <br>The Copy Constructor <br> Shallow Copying and Associated Problems <br> Ensuring a Deep Copy Using a Copy Constructor <br> Using Move Constructors to Improve Performance <br>Different Uses of Constructors and the Destructor<br> A Class That Does Not Permit Copying <br> A Singleton Class That Permits a Single Instance <br> A Class That Prohibits Instantiation on the Stack<br> Using Constructors to Convert Types <br>The this Pointer <br>Using sizeof() with a Class <br>The Keyword struct and Its Differences from class <br>Declaring a friend of a class <br>Union: A Special Data Storage Mechanism <br> Declaring a Union <br> Where Would You Use a Union?<br>Using Aggregate Initialization on Classes and structs <br> constexpr with Classes and Objects <br>Summary <br>Q&amp;A <br>Workshop<br> Quiz <br> Exercises<br><strong>Lesson 10:</strong> Implementing Inheritance<br>Basics of Inheritance<br> Inheritance and Derivation<br> C++ Syntax of Derivation<br> The Access Specifier Keyword protected <br> Base Class Initialization: Passing Parameters to the Base Class <br> A Derived Class Overriding the Base Class’s Methods <br> Invoking Overridden Methods of a Base Class <br> Invoking Methods of a Base Class in a Derived Class <br> A Derived Class Hiding the Base Class’s Methods <br> Order of Construction <br> Order of Destruction <br>Private Inheritance <br>Protected Inheritance <br>The Problem of Slicing <br>Multiple Inheritance <br>Avoiding Inheritance Using final <br>Summary <br>Q&amp;A <br>Workshop <br> Quiz <br> Exercises <br><strong>Lesson 11:</strong> Polymorphism<br>Basics of Polymorphism <br> Need for Polymorphic Behavior <br> Polymorphic Behavior Implemented Using Virtual Functions <br> Need for Virtual Destructors<br> How Do Virtual Functions Work? Understanding the Virtual Function Table <br> Abstract Base Classes and Pure Virtual Functions <br>Using Virtual Inheritance to Solve the Diamond Problem <br>Using the Specifier override to Indicate the Intention to Override<br>Using final to Prevent Function Overriding <br>Virtual Copy Constructors? <br>Summary <br>Q&amp;A <br>Workshop <br> Quiz <br> Exercises <br><strong>Lesson 12:</strong> Operator Types and Operator Overloading<br>What Are Operators in C++?<br>Unary Operators <br> Unary Increment (++) and Decrement (--) Operators <br> Conversion Operators <br> The Dereference Operator (*) and Member Selection Operator (-&gt;) <br>Binary Operators <br> The Binary Addition (a+b) and Subtraction (a-b) Operators <br> The Addition Assignment (+=) and Subtraction Assignment (-=) Operators <br> The Equality (==) and Inequality (!=) Operators <br> The &lt;, &gt;, &lt;=, and &gt;= Operators <br> The C++20 Three-Way Comparison Operator (&lt;=&gt;) <br> The Copy Assignment Operator (=) <br> The Subscript Operator ([]) <br>The Function Operator (()) <br>The Move Constructor and Move Assignment Operator for High-Performance Programming <br> The Problem of Unwanted Copy Steps <br> Declaring a Move Constructor and Move Assignment Operator <br>User-Defined Literals <br>Operators That Cannot Be Overloaded <br>Summary <br>Q&amp;A <br>Workshop <br> Quiz <br> Exercises <br><strong>Lesson 13:</strong> Casting Operators<br>The Need for Casting <br>Why C-Style Casts Are Not Popular with Some C++ Programmers <br>The C++ Casting Operators <br> Using static_cast <br> Using dynamic_cast and Runtime Type Identification <br> Using reinterpret_cast <br> Using const_cast <br>Problems with the C++ Casting Operators <br>Summary <br>Q&amp;A <br>Workshop <br> Quiz <br> Exercises <br><strong>Lesson 14:</strong> An Introduction to Macros and Templates<br>The Preprocessor and the Compiler <br>Using the Macro #define to Define Constants <br> Using Macros for Protection Against Multiple Inclusion <br>Using #define to Write Macro Functions <br> Why All the Parentheses?<br> Using the assert Macro to Validate Expressions<br> Advantages and Disadvantages of Using Macro Functions <br>An Introduction to Templates <br> Template Declaration Syntax <br> The Different Types of Template Declarations <br> Template Functions <br> Templates and Type Safety <br> Template Classes <br> Declaring Templates with Multiple Parameters <br> Declaring Templates with Default Parameters <br> Sample Template Class: HoldsPair<br> Template Instantiation and Specialization <br> Template Classes and static Members <br> Variable Templates <br> Using static_assert to Perform Compile-Time Checks<br> Using Templates in Practical C++ Programming <br>Summary <br>Q&amp;A <br>Workshop <br> Quiz <br> Exercises<br><strong>PART III: Learning the Standard Template Library (STL)<br>Lesson 15:</strong> An Introduction to the Standard Template Library<br>STL Containers <br> Sequential Containers <br> Associative Containers <br> Container Adapters <br>STL Iterators <br>STL Algorithms <br>Interaction Between Containers and Algorithms Using Iterators <br> Using the Keyword auto to Let a Compiler Define Type <br>Choosing the Right Container <br>STL String Classes<br>Summary <br>Q&amp;A <br>Workshop <br> Quiz <br><strong>Lesson 16:</strong> The STL String Class<br>The Need for String Manipulation Classes <br>Working with the STL string Class <br> Instantiating the STL string Class and Making Copies <br> Accessing Character Contents of std::string <br> Concatenating One String to Another <br> Finding a Character or Substring in a String <br> Truncating an STL String <br> String Reversal <br> String Case Conversion <br>Template-Based Implementation of an STL String <br>operator ""s in std::string<br>Using std::string_view (Amended in C++20) <br>Summary <br>Q&amp;A <br>Workshop <br> Quiz <br> Exercises<br><strong>Lesson 17:</strong> STL Dynamic Array Classes<br>The Characteristics of std::vector <br>Typical Vector Operations <br> Instantiating a Vector <br> Inserting Elements at the End of a Vector by Using push_back() <br> List Initialization <br> Inserting Elements at a Given Position by Using insert() <br> Accessing Elements in a Vector by Using Array Semantics <br> Accessing Elements in a Vector by Using Pointer Semantics <br> Removing Elements from a Vector <br>Understanding the Concepts of Size and Capacity<br>The STL deque Class <br>Summary <br>Q&amp;A <br>Workshop<br> Quiz <br> Exercises<br><strong>Lesson 18:</strong> STL list and forward_list<br>The Characteristics of std::list <br>Basic list Operations <br> Instantiating a std::list Object <br> Inserting Elements at the Front or Back of a List <br> Inserting Elements in the Middle of a List <br> Erasing Elements from a List<br>Reversing and Sorting Elements in a List <br> Reversing Elements by Using list::reverse()<br> Sorting Elements <br> Sorting and Removing Elements from a List That Contains Instances of a Class <br> std::forward_list <br>Summary <br>Q&amp;A <br>Workshop <br> Quiz <br> Exercises <br><strong>Lesson 19:</strong> STL set and multiset <br>An Introduction to STL Set Classes <br>Basic STL set and multiset Operations <br> Instantiating a std::set Object <br> Inserting Elements in a Set or Multiset <br> Finding Elements in an STL set or multiset Container <br> Erasing Elements in an STL set or multiset Container<br>Pros and Cons of Using STL set and multiset<br>STL Hash Set Implementation: std::unordered_set and std::unordered_multiset <br>Summary <br>Q&amp;A <br>Workshop <br> Quiz <br> Exercises<br><strong>Lesson 20:</strong> STL map and multimap<br>An Introduction to STL Map Classes <br>Basic std::map and std::multimap Operations <br> Instantiating std::map or std::multimap<br> Inserting Elements in an STL Map or Multimap <br> Finding Elements in an STL map Container<br> Finding Elements in an STL multimap Container <br> Erasing Elements from an STL map or multimap Container <br>Supplying a Custom Sort Predicate <br>STL’s Hash Table–Based Key/Value Container<br> How Hash Tables Work <br> Using unordered_map and unordered_multimap<br>Summary <br>Q&amp;A <br>Workshop<br> Quiz <br> Exercises<br><strong>PART IV: Lambda Expressions and STL Algorithms<br>Lesson 21:</strong> Understanding Function Objects<br>Function Objects and Predicates <br>Typical Applications of Function Objects <br> Unary Functions<br> Unary Predicates <br> Binary Functions <br> Binary Predicates<br>Summary <br>Q&amp;A <br>Workshop<br> Quiz <br> Exercises<br><strong>Lesson 22:</strong> Lambda Expressions<br>What Is a Lambda Expression? <br>How to Define a Lambda Expression <br> Capturing Variables <br> Parameters<br> Return Types<br>A Lambda Expression for a Unary Function<br>A Lambda Expression for a Unary Predicate <br>A Lambda Expression with State via Capture Lists ([.]) <br>A Lambda Expression for a Binary Function <br>A Lambda Expression for a Binary Predicate<br>Summary <br>Q&amp;A <br>Workshop<br> Quiz <br> Exercises<br><strong>Lesson 23:</strong> STL Algorithms<br>What Are STL Algorithms?<br>Classification of STL Algorithms<br> Non-mutating Algorithms<br> Mutating Algorithms<br>Usage of STL Algorithms <br> Finding Elements, Given a Value or a Condition<br> Counting Elements Given a Value or a Condition<br> Searching for an Element or a Range in a Collection <br> Initializing Elements in a Container to a Specific Value <br> Using std::generate() to Initialize Elements to a Value Generated at Runtime <br> Processing Elements in a Range by Using for_each()<br> Performing Transformations on a Range by Using std::transform() <br> Copy and Remove Operations <br> Replacing Values and Replacing Elements Given a Condition <br> Sorting and Searching in a Sorted Collection and Erasing Duplicates <br> Partitioning a Range <br> Inserting Elements in a Sorted Collection <br> Performing Fold Operations Using std::accumulate() in C++20 <br>C++20 Constrained Algorithms <br>Summary <br>Q&amp;A <br>Workshop <br> Quiz <br> Exercises <br><strong>Lesson 24:</strong> Adaptive Containers: Stack and Queue<br>The Behavioral Characteristics of Stacks and Queues<br> Stacks <br> Queues <br>Using the STL stack Class<br> Instantiating a Stack <br> Stack Member Functions<br> Insertion and Removal at the Top, Using push() and pop()<br>Using the STL queue Class<br> Instantiating a Queue <br> Member Functions of the queue Class<br> Insertion at the End and Removal at the Beginning of a Queue via push() and pop()<br>Using the STL Priority Queue<br> Instantiating the priority_queue Class <br> Member Functions of priority_queue <br> Insertion at the End and Removal at the Beginning of a Priority Queue via push() and pop() <br>Summary <br>Q&amp;A <br>Workshop <br> Quiz <br> Exercises <br><strong>Lesson 25:</strong> Working with Bit Flags Using the STL<br>The bitset Class <br> Instantiating std::bitset<br>Using std::bitset and Its Members <br> Useful Operators in std::bitset <br> std::bitset Member Methods <br>The vector&lt;bool&gt; Class <br> Instantiating vector&lt;bool&gt; <br> vector&lt;bool&gt; Functions and Operators<br>Summary <br>Q&amp;A <br>Workshop <br> Quiz <br> Exercises <br><strong>PART V: Advanced C++ Concepts</strong><br><strong>Lesson 26:</strong> Understanding Smart Pointers<br>What Are Smart Pointers? <br> The Problem with Using Conventional (Raw) Pointers <br> How Do Smart Pointers Help? <br>How Are Smart Pointers Implemented? <br>Types of Smart Pointers <br> Deep Copy <br> Copy on Write <br> Reference-Counted Smart Pointers <br> Reference-Linked Smart Pointers <br> Destructive Copy<br> Using std::unique_ptr<br>Popular Smart Pointer Libraries<br>Summary <br>Q&amp;A <br>Workshop<br> Quiz <br> Exercises<br><strong>Lesson 27:</strong> Using Streams for Input and Output<br>The Concept of Streams<br>Important C++ Stream Classes and Objects<br>Using std::cout for Writing Formatted Data to the Console <br> Changing the Display Number Format by Using std::cout <br> Aligning Text and Setting Field Width by Using std::cout<br>Using std::cin for Input <br> Using std::cin for Input into a Plain Old Data Type <br> Using std::cin::get for Input into the char* Buffer <br> Using std::cin for Input into std::string<br>Using std::fstream for File Handling <br> Opening and Closing a File Using open() and close() <br> Creating and Writing a Text File by Using open() and the Operator &lt;&lt; <br> Reading a Text File by Using open() and the Operator &gt;&gt; <br> Writing to and Reading from a Binary File <br>Using std::stringstream for String Conversions <br>Summary <br>Q&amp;A <br>Workshop <br> Quiz <br> Exercises <br><strong>Lesson 28:</strong> Exception Handling<br>What Is an Exception? <br>What Causes Exceptions? <br>Implementing Exception Safety via try and catch <br> Using catch(.) to Handle All Exceptions <br> Catching Exceptions of a Type <br>Throwing Exceptions of a Type by Using throw <br>How Exception Handling Works <br>Class std::exception <br>A Custom Exception Class Derived from std::exception <br>Summary <br>Q&amp;A <br>Workshop <br> Quiz <br> Exercises <br><strong>Lesson 29:</strong> C++20 Concepts, Ranges, Views, and Adaptors<br>Concepts <br> Using Concepts Provided by the Standard Library <br> Defining Custom Concepts by Using the Keyword requires <br> Using Concepts with Classes and Objects <br>The Ranges Library, Views, and Adaptors <br> Views and Adaptors <br> Adaptors Provided by the Ranges Library<br> Combining Multiple Adaptors <br>Summary <br>Q&amp;A <br>Workshop <br> Quiz <br> Exercises <br><strong>Lesson 30:</strong> C++20 Threads<br>Multithreading <br> What Is a Thread?<br> Why Program Multithreaded Applications?<br> Using the C++20 Thread Library <br> How Can Threads Transact Data? <br> Using Mutexes and Semaphores to Synchronize Threads<br>Summary <br>Q&amp;A <br>Workshop<br> Exercise<br><strong>Lesson 31:</strong> C++20 Modules and C++23<br>Modules <br> The Problem with #include&lt;header&gt; <br> C++20 Modules <br> Programming a Module <br> Consuming a Module <br>Why import Module; Is Superior to the Preprocessor #include&lt;header&gt; <br>C++23 Expected Features <br>Learning C++ Doesn’t Stop Here! <br> Online Documentation<br> Communities for Guidance and Help <br>Summary <br>Q&amp;A <br>Workshop <br> Exercise <br><strong>PART VI: Appendixes<br>Appendix A:</strong> Working with Numbers: Binary and Hexadecimal <br><strong>Appendix B:</strong> C++ Keywords <br><strong>Appendix C:</strong> Writing Great C++ Code <br><strong>Appendix D:</strong> ASCII Codes <br><strong>Appendix E:</strong> Answers <br>9780137334681 TOC 12/20/2021</p>

Managementboek Top 100

Rubrieken

Populaire producten

    Personen

      Trefwoorden

        C++ in One Hour a Day, Sams Teach Yourself