1.1.1. Introduction
This chapter, , provides an overview of this book, some hints about how to use it, and some background information about C++ and its use. You are encouraged to skim through it, read what appears interesting, and return to it after reading other parts of the book. Please do not feel obliged to read it all carefully before proceeding.
The following chapters provide an overview of the major concepts and features of the C++ programming language and its standard library:
This whirlwind tour of C++s facilities aims to give the reader a taste of what C++ offers. In particular, it should convince readers that C++ has come a long way since the first, second, and third editions of this book.
1.1.2. Basic Facilities
focuses on the subset of C++ that supports the styles of programming traditionally done in C and similar languages. It introduces the notions of type, object, scope, and storage. It presents the fundamentals of computation: expressions, statements, and functions. Modularity as supported by namespaces, source files, and exception handling is also discussed:
Types and Declarations: Fundamental types, naming, scopes, initialization, simple type deduction, object lifetimes, and type aliases
Pointers, Arrays, and References
Structures, Unions, and Enumerations
Statements: Declarations as statements, selection statements ( if and switch ), iteration statements ( for , while , and do ), goto , and comments
Expressions: A desk calculator example, survey of operators, constant expressions, and implicit type conversion.
Select Operations: Logical operators, the conditional expression, increment and decrement, free store ( new and delete ), {} -lists, lambda expressions, and explicit type conversion ( static_cast and const_cast )
Functions: Function declarations and definitions, inline functions, constexpr functions, argument passing, overloaded functions, pre- and postconditions, pointers to functions, and macros
Exception Handling: Styles of error handling, exception guarantees, resource management, enforcing invariants, throw and catch , a vector implementation
Namespaces: namespace , modularization and interface, composition using namespaces
Source Files and Programs: Separate compilation, linkage, using header files, and program start and termination
I assume that you are familiar with most of the programming concepts used in . For example, I explain the C++ facilities for expressing recursion and iteration, but I do not go into technical details or spend much time explaining how these concepts are useful.
The exception to this rule is exceptions. Many programmers lack experience with exceptions or got their experience from languages (such as Java) where resource management and exception handling are not integrated. Consequently, the chapter on exception handling () presents the basic philosophy of C++ exception handling and resource management. It goes into some detail about strategy with a focus on the Resource Acquisition Is Initialization technique (RAII).
1.1.3. Abstraction Mechanisms
describes the C++ facilities supporting various forms of abstraction, including object-oriented and generic programming. The chapters fall into three rough categories: classes, class hierarchies, and templates.
The first four chapters concentrate of the classes themselves:
Classes: The notion of a user-defined type, a class, is the foundation of all C++ abstraction mechanisms.
Construction, Cleanup, Copy, and Move shows how a programmer can define the meaning of creation and initialization of objects of a class. Further, the meaning of copy, move, and destruction can be specified.