- Learn C++ fast! Real code, thoroughly explained-and ready to use!
- Completely updated with over 200 new examples
- All the fundamentals: variables, operators, arrays, functions, program
control, I/O, files, streams, memory management, sorts, searches, and more
- Advanced topics: data structures, templates, string classes, and exception
handling
- See the code and put it to work—fast, easy, and hands on
C++ Programmer's Notebook, Second Edition teaches C++ the way you want
to learn it: with real code! This quick, visual tutorial presents hundreds of
annotated "snapshots" of working code, covering all the C++ concepts and
techniques you need—and delivering specific solutions you can use right now!
Practical, comprehensive coverage includes:
- Variables, operators, expressions, arrays, and C-style strings
- Structures, functions, and program control
- Objects, classes, overloading, inheritance, and pointers
- Virtual and friend functions
- I/O, files, streams, and memory management
- Sorts and searches
- Data structures and templates
- String classes and exception handling
- Quality checklists for building robust, high-performance code!
Completely updated with over 200 new examples, C++ Programmer's Notebook,
Second Edition is the perfect starting point for new C++ developers-and the
perfect reference for experienced C++ developers looking for quick
solutions!
Table of Contents
Preface.
1. Working with Variables.
Naming Variables. Using Variables. Boolean
Variables. Integer Variables. Character Variables. Escape Sequences. Floating
Point Variables. Inside Exponential Notation. Data Type Conversion. Assigning
Values to Variables. Constants. Scope. Local Variables versus Global Variables.
File and Class Scope. Storage Specifiers. Static. Register. Auto. Storage
Specifier Rules.
2. Working with Operators and Expressions.
Expressions. Arithmetic Operators. The +=, -=,
*=, /= Operators. The ++, -- Operators. Relational Operators. The == and !=
Operators. Logical Operators. Bitwise Operators. Bitwise AND. Bitwise OR.
Bitwise XOR (exclusive OR). Bitwise NOT. The Shift Left Operator. The Shift
Right Operator. ?-The Conditional Operator. An Introduction to Indirection. The
Precedence Table. Working with Expressions.
3. Working with Arrays and C-Style Strings.
Arrays and Strings. Assigning Values to an
Array. Multidimensional Arrays. Assigning Values to a Multidimensional Array.
Allocating Arrays Using the new Operator. Allocating Multidimensional Arrays
Using the new Operator. C-Style Strings. Copying One C-Style String to Another
Using strcpy( ) and strncpy( ). Reading in a C-Style String Using gets( )and
fgets( ). Reading a C-Style String from the Keyboard Using scanf( ). Reading a
C-Style String from the Keyboard with the Extraction Operator. Reading a C-Style
String from the Keyboard with get( ) and getline( ). Comparing Two C-Style
Strings. Displaying a C-Style String with printf( ). Displaying a C-Style String
with puts( ). Displaying a String with the Insertion Operator. Concatenating
C-Style Strings with strcat( ) and strncat( ). Determining the Length of a
C-Style String with strlen( ). Determining the Length of a Substring with
strcspn( ). Determining the Length of a Substring with strspn( ). Locating a
Character within a C-Style String Using strpbrk( ). Locating the First
Occurrence of a Substring in a C-Style String with strstr( ). Dividing a C-Style
String into Several Substrings Using strtok( ). C-Style Strings versus the
String Types of the C++ Standard Library.
4. Working with Structures.
Structures. A Structure at Work. Running the
Sample Program. Other Ways to Declare an Instance of a Structure. Assigning
Values to Structure Members. Multiple Instances of Structures. Assigning Values
to Multiple Instances. Structures within Structures. Passing Members of a
Structure to a Function. Passing Members by Address. Passing a Structure to a
Function. Passing a Structure to a Function by Reference. Functions Returning
Structures. Unions. Enumerations. The typedef Declaration.
5. Working with Functions.
Anatomy of a C++ Program. The main( ) Function.
How to Use a Function. Passing Arguments by Value. Passing Multiple Arguments.
Passing Arguments Using Reference Variables. Passing Arguments to the main( )
Function. Returning Values. Building a Program Using Functions. Additional
Function Facts. Program Statements. White Space Characters. Preprocessor
Directives. More Preprocessor Directives. #define with Arguments. inline
Function. #if, #else, #elif, #endif. #ifdef, #ifndef, #undef. Using Include Once
Header Files. #line, #error, and #pragma.
6. Working with Program Control.
Program Control Statements. The if Statement.
The if...else Statement. The ? Operator. Nested if. Multiple Conditions. The
switch...case Statement. Tricks of the Trade. for Loop. More on for Loops. while
Loop. do...while Loop. break. Continue. exit( ). goto.
7. Working with Objects and Classes.
Classes. Declaring an Instance of a Class.
Hiding Data Using the Access Control Specifier. The Constructor. More on
Initialization. The Destructor. The Copy Constructor. Defining a Function Member
outside the Class Declaration.
8. Working with Overloading.
Overloading. Overloading a Unary Operator.
Overloading a Binary Operator. Overloading the Input and Output Operators.
Operators that Can and Cannot Be Overloaded.
9. Working with Inheritance.
Inheritance. Access Specifiers. More about
Inheritance. Multiple Inheritance. Ambiguity in Multiple Inheritance.
Containership Class. Levels of Inheritance.
10. Working with Pointers.
Pointers and References. More on Using Pointers.
Incrementing Pointers. Decrementing Pointers. Pointer Math. An Array of
Pointers. Pointer-to-a-Pointer. Pointer-to-a-Function. Tricks of the Trade.
11. Working with Virtual and Friend Functions.
Creating a Virtual Function. Virtual
Destructors. Creating a Pure Virtual Function. More about Virtual Functions.
Friend Functions. Creating a Friend Function from a Function Member Forward
Reference of a Class. Friend Classes.