C++20 in Examples

C++20 in Examples

English | 2020 | 390 Pages | PDF | 10 MB

This book is about C++. It consists of examples that cover all main subjects essential for programming in C++.

Chapter 1 gives a general notion of what we can do in C++. There we learn how to create a program. The chapter also contains information about input and output operators, variables, functions, loop statements, conditional statements, and arrays.

Chapter 2 is devoted to the control statements. In this chapter, we consider in detail the conditional statement, loop statements, the selection statement. We also will get a notion about handling and throwing exceptions.

In Chapter 3, we discuss pointers, arrays, and references. Namely, we consider how to create and use pointers. We discuss the relationship between pointers and arrays, and also we investigate how and when we can use references. Moreover, the chapter contains information about memory allocation. As well, there we analyze the peculiarities of character arrays used to implement strings.

Chapter 4 is about functions. There we learn what a function can do and how we can use it. We overload functions, define the arguments with default values, and use recursion. We will get to know how arguments are passed to functions and how we pass a function as an argument. Also, we learn how functions operate with arrays, references, and pointers.

In Chapter 5, we discuss the principles of object-oriented programming. We learn how to describe classes and create objects. Also, the chapter contains information about public and private members, constructors and destructors, overloading methods and operators, using inheritance.

In Chapter 6, we continue discussing classes and objects. Namely, we get familiar with pointers to objects, arrays of objects, and functors. We will use objects whose fields are arrays and implement object indexing. We will get familiar with virtual methods and multiple inheritance, and do some other tricks with classes and objects.

In Chapter 7, we investigate template functions and classes. There we create and overload template functions with several parameters. We will come to know how to define default values for template parameters. There we also apply inheritance for template classes. Moreover, in the chapter, we consider how to use integer template parameters.

In Chapter 8, we consider different programs. The chapter explains how to use structures, complex numbers, and containers. We will also get familiar with multithreading.

Chapter 9 is devoted to mathematical problems. In that chapter, we show how to implement methods for solving algebraic and differential equations, calculate integrals, and create interpolation polynomials.