Free E-book C++: The Complete Reference Third Edition
Free E-book C++: The Complete Reference Third Edition
Part I The Foundation of C++: The C Subset
1 An Overview of C . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2 Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
3 Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
4 Arrays and Null-Terminated Strings . . . . . . . . . . . . . . . . 89
5 Pointers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
6 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
7 Structures, Unions, Enumerations, and User-
Defined Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161
8 C-Style Console I/O . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187
9 File I/O . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211
10 The Preprocessor and Comments . . . . . . . . . . . . . . . . . . . 237
Part II C++
11 An Overview of C++ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255
12 Classes and Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289
13 Arrays, Pointers, References and the Dynamic
Allocation Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . 327
14 Function Overloading, Copy Constructors,
and Default Arguments . . . . . . . . . . . . . . . . . . . . . . . . 361
15 Operator Overloading
16 Inheritance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 419
17 Virtual Functions and Polymorphism . . . . . . . . . . . . . . 445
18 Templates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 461
19 Exception Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 489
20 C++ I/O System Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . 511
21 C++ File I/O . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 541
22 Run-Time Type ID and the Casting Operators . . . . . . . . 569
23 Namespaces, Conversion Functions,and Other
Advanced Topics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 593
24 Introducing the Standard Template Library . . . . . . . . . . 625
Part III The Standard Function Library
25 The C-Based I/O Functions . . . . . . . . . . . . . . . . . . . . . . . . 695
26 The String and Character Functions . . . . . . . . . . . . . . . . . 719
27 The Mathematical Functions . . . . . . . . . . . . . . . . . . . . . . . 733
28 Time, Date, and Localization Functions . . . . . . . . . . . . . . 743
29 The Dynamic Allocation Functions . . . . . . . . . . . . . . . . . . 753
30 Utility Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 757
31 The Wide-Character Functions . . . . . . . . . . . . . . . . . . . . . 771
Part IV The Standard C++ Class Library
32 The Standard C++ I/O Classes . . . . . . . . . . . . . . . . . . . . . 783
33 The STL Container Classes . . . . . . . . . . . . . . . . . . . . . . . . . 807
34 The STL Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 835
35 STL Iterators, Allocators, and Function Objects . . . . . . . 857
36 The String Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 877
37 The Numeric Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 893
38 Exception Handling and Miscellaneous Classes . . . . . . . 921
Part V Applying C++
39 Integrating New Classes: A Custom String Class . . . . . . 931
40 An Object-Oriented Expression Parser . . . . . . . . . . . . . . . 959
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
*********************************************************************************
This book divides the description of the C++ language into two parts. Part One discusses the C-like features of C++.
This is commonly referred to as the C subset of C++. Part Two describes those features specific to C++.
Together, they describe the entire C++ language.
As you may know, C++ was built upon the foundation of C.
In fact, C++ includes the entire C language, and (with minor exceptions) all C programs are also C++ programs. When C++ was invented, the C language was used as the starting point. To C were added several new features and extensions designed to support object-oriented programming (OOP). However, the C-like aspects of C++ were never abandoned, and the ANSI/ISO C standard is a base document for
the International Standard for C++. Thus, an understanding of C++ implies an understanding of C.
In a book such as this Complete Reference, dividing the C++ language into two pieces—the C foundation and the C++-specific features—achieves three major benefits:
1. The dividing line between C and C++ is clearly delineated.
2. Readers already familiar with C can easily find the C++-specific information.
3. It provides a convenient place in which to discuss those features of C++ that relate mostly to the C subset.
Understanding the dividing line between C and C++ is important because both are widely used languages and it is very likely that you will be called upon to write or maintain both C and C++ code. When working on C code, you need to know where C ends and C++ begins. Many C++ programmers will, from time to time, be required to write code that is limited to the "C subset." This will be especially true for embedded systems programming and the maintenance of existing applications. Knowing the difference between C and C++ is simply part of being a top-notch professional C++ programmer.
A clear understanding of C is also valuable when converting C code into C++. To do this in a professional manner, a solid knowledge of C is required. For example, without a thorough understanding of the C I/O system, it is not possible to efficiently convert an I/O-intensive C program into C++.
Many readers already know C. Covering the C-like features of C++ in their own section makes it easier for the experienced C programmer to quickly and easily find information about C++ without having to wade through reams of information that he or she already knows. Of course, throughout Part One, any minor differences between C and C++ are noted. Also, separating the C foundation from the more advanced, object-oriented features of C++ makes it possible to tightly focus on those advanced features because all of the basics will have already been discussed.
Although C++ contains the entire C language, not all of the features provided by the C language are commonly used when writing "C++-style" programs. For example, the C I/O system is still available to the C++ programmer even though C++ defines its own, object-oriented version. The preprocessor is another example. The preprocessor is very important to C, but less so to C++. Discussing several of the "C-only" features in Part One prevents them from cluttering up the remainder of the book....
Free E-book C++: The Complete Reference Third Edition
0 commentaires: