万本电子书0元读

万本电子书0元读

顶部广告

C++ Fundamentals电子书

售       价:¥

4人正在读 | 0人评论 9.8

作       者:Antonio Mallia

出  版  社:Packt Publishing

出版时间:2019-03-15

字       数:1115.0万

所属分类: 进口书 > 外文原版书 > 电脑/网络

温馨提示:数字商品不支持退换货,不提供源文件,不支持导出打印

为你推荐

  • 读书简介
  • 目录
  • 累计评论(0条)
  • 读书简介
  • 目录
  • 累计评论(0条)
Write high-level abstractions while retaining full control of the hardware, performances, and maintainability. Key Features * Transform your ideas into modern C++ code, with both C++11 and C++17 * Explore best practices for creating high-performance solutions * Understand C++ basics and work with concrete real-world examples Book Description C++ Fundamentals begins by introducing you to the C++ syntax. You will study the semantics of variables along with their advantages and trade-offs, and see how they can be best used to write safe and efficient code. With the help of this book, you’ll be able to compile fully working C++ programs and understand how variables, references, and pointers can be used to manipulate the state of the program. Then you'll explore functions and classes — the features that C++ offers to organize a program — and use them to solve more complex problems such as functions and classes. You’ll also understand common pitfalls and modern best practices, especially the ones that diverge from the C++98 guideline. As you advance through the chapters, you’ll study the advantages of generic programming and write your own templates to make generic algorithms that work with any type. This C++ book will guide you in fully exploiting standard containers and understanding how to pick the appropriate container for each problem. You will even work with a variety of memory management tools in C++. By the end of this book, you will not only be able to write efficient code, but also be equipped to improve the readability, performance, and maintainability of your programs using standard algorithms. What you will learn * Work with the C++ compilation model and syntaxes * Apply best practices for writing functions and classes * Write safe, generic, and efficient code with templates * Explore the containers that C++ standard offers * Discover the new paradigms introduced with C++11, C++14, and C++17 * Get to grips with the core language features of C++ * Abstract complex problems using object-oriented programming in C++ Who this book is for If you’re a developer looking to learn a new powerful language or are familiar with C++ but want to update your knowledge with modern paradigms of C++11, C++14, and C++17, this book is for you. To easily understand the concepts in the book, you must be familiar with the basics of programming.
目录展开

Preface

About the Book

About the Authors

Objectives

Audience

Approach

Minimum Hardware Requirements

Software Requirements

Additional Resources

Conventions

Chapter 1

Getting Started

Introduction

The C++ Compilation Model

Difference Between Header and Source Files

Compiling a File into an Object File

Linking Object Files

Working with the main Function

Exercise 1: Compiling and Executing the main Function

Built-in Data Types

Primitive Data Types

Datatype Modifiers

Variable Definition

Demystifying Variable Initialization

Pointers and References

Pointers

References

The const Qualifier

The Scope of Variables

Control Flow Statements

Selection Statement – if-else

Selection Statement – switch

Iteration Statement – for loop

Iteration Statement – while loop

Iteration Statement – do-while loop

Jump Statements – break and continue

The try-catch block

Exercise 2: Counting the Number of Times a Specific Number Appears in a Given List

Activity 1: Finding the Factors of 7 between 1 and 100 Using a while Loop

Arrays

Array Declaration

Array Initialization

Accessing the Values of an Array

Multidimensional Arrays

Activity 2: Defining a Bi-Dimensional Array and Initializing Its Elements

Summary

Chapter 2

Functions

Introduction

Function Declaration and Definition

Defining a Function

Exercise 3: Calling a Function from main()

Local and Global Variables

Working with Variable Objects

Exercise 4: Using Local and Global Variables in a Fibonacci Sequence

Passing Arguments and Returning Values

Pass by Value

Exercise 5: Calculating Age using Pass by Value Arguments

Pass by Reference

Exercise 6: Calculating Incrementation of Age using Pass by Reference

Activity 3: Checking Voting Eligibility

Working with const References or r-value References

Returning Values from Functions

Returning by Value

Returning by Reference

Activity 4: Using Pass by Reference and Pass by Value

Const Parameters and Default Arguments

Passing by const Value

Passing by const Reference

Returning by const Value

Returning by const Reference

Default Arguments

Namespaces

Activity 5: Organizing Functions in Namespaces

Function Overloading

Activity 6: Writing a Math Library for a 3D Game

Summary

Chapter 3

Classes

Introduction

Declaring and Defining a Class

The Advantages of Using Classes

C++ Data Members and Access Specifiers

Static Members

Exercise 7: Working with Static Variables

Member Functions

Declaring a Member Function

Using const Member Functions

The this Keyword

Exercise 8: Creating a Program Using the this Keyword to Greet New Users

Non-Member Class-Related Functions

Activity 7: Information Hiding Through Getters and Setters

Constructors and Destructors

Constructors

Overloading Constructor

Constructor Member Initialization

Aggregate Classes Initialization

Destructors

Exercise 9: Creating a Simple Coordinate Program to Demonstrate the Use of Constructors and Destructors

Default Constructor and Destructor

Activity 8: Representing Positions in a 2D Map

Resource Acquisition Is Initialization

Activity 9: Storing Multiple Coordinates of Different Positions on a Map

Nested Class Declarations

Friend Specifier

Friend Functions

Friend Classes

Exercise 10: Creating a Program to Print the User's Height

Activity 10: The AppleTree Class, which Creates an Apple Instance

Copy Constructors and Assignment Operators

The copy Assignment Operator

The move-constructor and move-assignment Operator

Preventing Implicit Constructors and Assignment Operators

Operator Overloading

Activity 11: Ordering Point Objects

Introducing Functors

Activity 12: Implementing Functors

Summary

Chapter 4

Generic Programming and Templates

Introduction

Templates

Compiling the Template Code

Exercise 11: Finding the Bank Account of the User with the Highest Balance

Using Template Type Parameters

Requirements of Template Parameter Types

Defining Function and Class Templates

Function Template

Class Templates

Dependent Types

Activity 13: Reading Objects from a Connection

Activity 14: Creating a User Account to Support Multiple Currencies

Non-Type Template Parameters

Activity 15: Writing a Matrix Class for Mathematical Operations in a Game

Making Templates Easier to Use

Default Template Arguments

Template Argument Deduction

Parameter and Argument Types

Activity 16: Making the Matrix Class Easier to Use

Being Generic in Templates

Activity 17: Ensuring Users are Logged in When Performing Actions on the Account

Variadic Templates

Activity 18: Safely Performing Operations on the User Cart with an Arbitrary Number of Parameters

Writing Easy-to-Read Templates

Type Alias

Template Type Alias

Summary

Chapter 5

Standard Library Containers and Algorithms

Introduction

Sequence Containers

Array

Vector

Deque

List

Forward-List

Providing Initial Values to Sequence Containers

Activity 19: Storing User Accounts

Associative Containers

Set and Multiset

Map and Multimap

Activity 20: Retrieving a User's Balance from their Given Username

Unordered Containers

Container Adaptors

Stack

Queue

Priority Queue

Activity 21: Processing User Registration in Order

Unconventional Containers

Strings

Exercise 12: Demonstrating Working Mechanism of the c_str() Function

Pairs and Tuples

std::optional

std::variant

Exercise 13: Using Variant in the Program

Exercise 14: Visitor Variant

Activity 22: Airport System Management

Iterators

Exercise 15: Exploring Iterator

Reverse Iterators

Exercise 16: Exploring Functions of Reverse Iterator

Insert Iterators

Stream Iterators

Exercise 17: Stream Iterator

Iterator Invalidation

Exercise 18: Printing All of the Customers' Balances

Algorithms Provided by the C++ Standard Template Library

Lambda

Read-Only Algorithms

Modifying Algorithms

Mutating Algorithms

Sorting Algorithms

Binary Search Algorithms

Numeric Algorithms

Exercise 19: Customer Analytics

Summary

Chapter 6

Object-Oriented Programming

Introduction

Inheritance

Exercise 20: Creating a Program to Illustrate Inheritance in C++

Exercise 21: Using Multiple Inheritance to Create a "Welcome to the Community" Message Application

Activity 23: Creating Game Characters

Polymorphism

Dynamic Binding

Virtual Methods

Exercise 22: Exploring the Virtual Method

Activity 24: Calculating Employee Salaries

Interfaces in C++

Activity 25: Retrieving User Information

Dynamic Memory

Safe and Easy Dynamic Memory

A Single Owner Using std::unique_ptr

Shared Ownership Using std::shared_ptr

Activity 26: Creating a Factory for UserProfileStorage

Activity 27: Using a Database Connection for Multiple Operations

Summary

Appendix

Lesson 1: Getting Started

Activity 1: Find the Factors of 7 between 1 and 100 Using a while Loop

Activity 2: Define a Bi-Dimensional Array and Initialize Its Elements

Lesson 2: Functions

Activity 3: Calculating if a Person is Eligible to Vote or Not

Activity 4: Apply the Understanding of Passing by Reference or Value in Functions

Activity 5: Organizing Functions in Namespaces

Activity 6: Writing a Math Library for use in a 3D Game

Lesson 3: Classes

Activity 7: Information Hiding Through Getters and Setters

Activity 8: Representing Positions in a 2D Map

Activity 9: Storing Multiple Coordinates of Different Positions in the Map

Activity 10: The AppleTree Class, which Creates an Apple Instance

Activity 11: Ordering Point Objects

Activity 12: Implementing Functors

Lesson 04: Generic Programming and Templates

Activity 13: Read Objects from a Connection

Activity 14: UserAccount to Support Multiple Currencies

Activity 15: Write a Matrix Class for Mathematical Operations in a Game

Solution bonus step:

Activity 16: Make the Matrix Class Easier to Use

Activity 17: Ensure Users are Logged in When Performing Actions on the Account

Activity 18: Safely Perform Operations on User Cart with an Arbitrary Number of Parameters

Lesson 5: Standard Library Containers and Algorithms

Activity 19: Storing User Accounts

Activity 20: Retrieving a User’s Balance from their Given Username

Activity 21: Processing User Registration in Order

Activity 22: Airport System Management

Lesson 6: Object-Oriented Programming

Activity 23: Creating Game Characters

Activity 24: Calculating Employee Salaries

Activity 25: Retrieving User Information

Activity 26: Creating a Factory for UserProfileStorage

Activity 27: Using a Database Connection for Multiple Operations

累计评论(0条) 0个书友正在讨论这本书 发表评论

发表评论

发表评论,分享你的想法吧!

买过这本书的人还买过

读了这本书的人还在读

回顶部