Introduction | p. 1 |
What's in This Book | p. 1 |
What's on the CD | p. 2 |
What Is C++? | p. 2 |
Conventions Used in This Book | p. 3 |
What You're Not to Read | p. 3 |
Foolish Assumptions | p. 4 |
How This Book Is Organized | p. 4 |
Icons Used in This Book | p. 7 |
Where to Go from Here | p. 7 |
Introducing C++ Programming | p. 9 |
Writing Your First C++ Program | p. 11 |
Grasping C++ Concepts | p. 12 |
What's a program? | p. 12 |
How do I program? | p. 13 |
Installing GNU C++ | p. 14 |
Creating Your First C++ Program | p. 14 |
Entering the C++ code | p. 14 |
Building your program | p. 16 |
Executing Your Program | p. 18 |
GNU is guh-not Windows | p. 19 |
GNU C++ help | p. 19 |
Reviewing the Annotated Program | p. 19 |
Examining the framework for all C++ programs | p. 20 |
Clarifying source code with comments | p. 20 |
Basing programs on C++ statements | p. 21 |
Writing declarations | p. 21 |
Generating output | p. 22 |
Calculating Expressions | p. 22 |
Storing the results of expression | p. 23 |
Examining the remainder of Conversion | p. 23 |
Declaring Variables Constantly | p. 25 |
Declaring Variables | p. 26 |
Declaring Different Types of Variables | p. 26 |
Reviewing the limitations of integers in C++ | p. 27 |
Solving the truncation problem | p. 28 |
Examining the limitations of floating point | p. 29 |
Declaring Variable Types | p. 30 |
Types of constants | p. 31 |
Special characters | p. 32 |
Mixed Mode Expressions | p. 33 |
Performing Mathematical Operations | p. 35 |
Performing Simple Binary Arithmetic | p. 36 |
Decomposing Expressions | p. 37 |
Determining the Order of Operations | p. 38 |
Performing Unary Operations | p. 39 |
Using Assignment Operators | p. 40 |
Performing Logical Operations | p. 43 |
Why Mess with Logical Operations? | p. 43 |
Using the Simple Logical Operators | p. 44 |
Be careful performing logical operations on floating point variables | p. 45 |
Expressing Binary Numbers | p. 47 |
The decimal number system | p. 48 |
Other number systems | p. 48 |
The binary number system | p. 48 |
Performing Bitwise Logical Operations | p. 50 |
The single bit operators | p. 51 |
Using the bitwise operators | p. 51 |
A simple test | p. 52 |
Why define such a crazy operator? | p. 54 |
Controlling Program Flow | p. 57 |
Controlling Program Flow with the Branch Commands | p. 57 |
Executing Loops in a Program | p. 59 |
Looping while a condition is true | p. 59 |
Using the autoincrement/autodecrement feature | p. 61 |
Using the for loop | p. 62 |
Avoiding the dreaded infinite loop | p. 65 |
Applying special loop controls | p. 65 |
Nesting Control Commands | p. 67 |
Switching to A Different Subject? | p. 69 |
Becoming a Functional Programmer | p. 71 |
Creating Functions | p. 73 |
Writing and Using a Function | p. 74 |
Understanding the Details of Functions | p. 76 |
Understanding Simple functions | p. 77 |
Understanding functions with arguments | p. 77 |
Overloading Function Names | p. 80 |
Defining Function Prototypes | p. 82 |
Variable Storage Types | p. 84 |
Storing Sequences in Arrays | p. 85 |
Considering the Need for Arrays | p. 85 |
Using an array | p. 87 |
Initializing an array | p. 89 |
Accessing too far into an array | p. 90 |
Using arrays? | p. 91 |
Defining and using arrays of arrays | p. 91 |
Using Arrays of Characters | p. 92 |
Manipulating Strings | p. 94 |
Writing our own concatenate function | p. 94 |
Reviewing the C++ string handling functions | p. 96 |
Handling wide characters | p. 97 |
Avoiding Obsolescent Output Functions | p. 98 |
Taking a First Look at C++ Pointers | p. 99 |
What's in an Address? | p. 99 |
Using Pointer Variables | p. 101 |
Comparing pointers and houses | p. 102 |
Using different types of pointers | p. 103 |
Passing Pointers to Functions | p. 105 |
Passing by value | p. 105 |
Passing pointer values | p. 106 |
Passing by reference | p. 107 |
Making Use of a Block of Memory Called the Heap | p. 107 |
Limiting scope | p. 108 |
Examining the scope problem | p. 109 |
Providing a solution using the heap | p. 110 |
Taking a Second Look at C++ Pointers | p. 111 |
Defining Operations on Pointer Variables | p. 111 |
Re-examining arrays in light of pointer variables | p. 112 |
Applying operators to the address of an array | p. 114 |
Expanding pointer operations to a string | p. 115 |
Applying operators to pointer types other than char | p. 119 |
Contrasting a pointer with an array | p. 119 |
Declaring and Using Arrays of Pointers | p. 121 |
Utilizing arrays of character strings | p. 122 |
Accessing the arguments to main() | p. 123 |
Remaining Functional Features | p. 125 |
Breaking Programs Apart? | p. 125 |
Looking at a Large Program | p. 126 |
Examining the Divided FunctionDemo Program | p. 127 |
Separating off the sumSequence() module | p. 128 |
Generating the remnant MainFunction.cpp module | p. 130 |
Creating the project file | p. 131 |
Creating a project file under GNU C++ | p. 131 |
Creating a project file under Visual C++ | p. 132 |
Including the #include Directive | p. 133 |
Using the Standard C++ Library | p. 134 |
Debugging C++ | p. 135 |
Identifying Types of Errors | p. 135 |
Choosing the WRITE Technique for the Problem | p. 136 |
Catching bug | p. 137 |
Catching bug #2 | p. 140 |
Calling for the Debugger | p. 143 |
Defining the debugger | p. 144 |
Deciding which debugger to use | p. 144 |
Running a test program | p. 145 |
Single-stepping through a program | p. 147 |
Single-stepping into a function | p. 148 |
Using breakpoints | p. 149 |
Viewing and modifying variables | p. 150 |
Budget 1 Program | p. 153 |
Programming with Class | p. 159 |
Examining Object-Oriented Programming | p. 161 |
Abstracting Microwave Ovens | p. 161 |
Preparing functional nachos | p. 162 |
Preparing object-oriented nachos | p. 163 |
Classifying Microwave Ovens | p. 163 |
Why Classify? | p. 164 |
Adding Class to C++ | p. 165 |
Introducing the Class | p. 165 |
The format of a Class | p. 166 |
Accessing the members of a Class | p. 167 |
Example program | p. 168 |
Making Classes Work | p. 173 |
Activating Our Objects | p. 174 |
Simulating real world objects | p. 174 |
Why bother with member functions? | p. 175 |
Adding a Member Function | p. 175 |
Creating a member function | p. 176 |
Naming class members | p. 177 |
Calling a Member Function | p. 177 |
Accessing a member function | p. 178 |
Accessing other members from a member function | p. 179 |
Scope Resolution (And I Don't Mean How Well Your Microscope Works) | p. 180 |
Defining a Member Function in the Class | p. 182 |
Keeping a Member Function After Class | p. 184 |
Overloading Member Functions | p. 185 |
Creating Pointers to Objects | p. 187 |
Defining Arrays of and Pointers to Simple Things | p. 187 |
Declaring Arrays of Objects | p. 188 |
Declaring Pointers to Objects | p. 189 |
Dereferencing an object pointer | p. 190 |
Shooting arrow pointers | p. 191 |
Passing Objects to Functions | p. 191 |
Calling a function with an object value | p. 191 |
Calling a function with an object pointer | p. 192 |
Why pass pointers to functions when you can pass the object itself? | p. 193 |
Calling a function by using the reference operator | p. 196 |
Returning to the Heap | p. 196 |
Linking up with Linked Lists | p. 197 |
The array data structure | p. 197 |
The linked list | p. 198 |
Performing other operations on a linked list | p. 199 |
Properties of linked lists | p. 201 |
Hooking Up with a LinkedListData Program | p. 201 |
Protecting Members: Do Not Disturb | p. 205 |
Protecting Members | p. 205 |
Why you need protected members | p. 205 |
Discovering how protected members work | p. 206 |
Making an Argument for Using Protected Members | p. 208 |
Protecting the internal state of the class | p. 208 |
Using a class with a limited interface | p. 209 |
Giving Non-Member Functions Access to Protected Members | p. 209 |
Why do I need friends? (I am a rock, I am an island) | p. 209 |
Building and Tearing Down Objects: The Constructor and Destructor | p. 213 |
Creating Objects | p. 213 |
Using Constructors | p. 214 |
Explaining the need for constructors | p. 214 |
Making constructors work | p. 216 |
Understanding the Destructor | p. 220 |
Why you need the destructor | p. 220 |
Working with destructors | p. 220 |
Making Constructive Arguments | p. 223 |
Outfitting Constructors with Arguments | p. 223 |
Justifying constructors | p. 224 |
Using a constructor? | p. 224 |
Overloading the Constructor (Is That Like Placing Too Many Demands on the Carpenter?) | p. 227 |
Defaulting Default Constructors | p. 229 |
Constructing Class Members | p. 231 |
Constructing the Order of Construction | p. 236 |
Local objects construct in order | p. 236 |
Static objects construct only once | p. 236 |
All global objects construct before main() | p. 237 |
Global objects construct in no particular order | p. 238 |
Members construct in the order in which they are declared | p. 239 |
Destructors destruct in the reverse order of the constructors | p. 240 |
Copying the Copy Copy Copy Constructor | p. 241 |
Copying an Object | p. 241 |
Why do I need it? | p. 241 |
Using the copy constructor | p. 242 |
The Automatic Copy Constructor | p. 244 |
Creating Shallow Copies versus Deep Copies | p. 246 |
It's a Long Way to Temporaries | p. 249 |
Static Members: Can Fabric Softener Help? | p. 253 |
Defining a Static Member | p. 253 |
Why do I need them? | p. 253 |
Using static members | p. 254 |
Referencing static data members | p. 255 |
Uses for static data members | p. 257 |
Declaring Static Member Functions | p. 257 |
A Budget with Class--Budget2.CPP | p. 261 |
Class Inheritance | p. 271 |
Inheriting a Class | p. 273 |
Do I Need Inheritance? | p. 274 |
How Does a Class Inherit? | p. 276 |
Constructing a Subclass | p. 278 |
Having a HAS_A Relationship | p. 279 |
Examining Virtual Member Functions: Are They for Real? | p. 281 |
Why Do I Need Polymorphism? | p. 284 |
How Does Polymorphism Work? | p. 286 |
Making Nachos the Polymorphic Way | p. 288 |
When Is a Virtual Function Not? | p. 290 |
Considering Virtual Considerations | p. 293 |
Factoring Classes | p. 295 |
Factoring | p. 296 |
Implementing Abstract Classes | p. 300 |
Describing the abstract class concept | p. 302 |
Making an honest class out of an abstract class | p. 303 |
Passing abstract classes | p. 305 |
Declaring pure virtual functions--is it really necessary? | p. 306 |
Trying to Rationalize My Budget: BUDGET3.CPP | p. 308 |
Optional Features | p. 319 |
Overloading Operators | p. 321 |
Overloading Operators--Can't We Live Together in Harmony? | p. 322 |
How Does an Operator Function and a Function Operate? | p. 323 |
Taking a More Detailed Look | p. 326 |
Considering the operator+O case | p. 326 |
Considering the operator++O case | p. 328 |
Coding Operators as Member Functions | p. 329 |
Suffering through Yet Another Overloading Irritation | p. 331 |
Overloading Operators Using Implicit Conversion | p. 332 |
Promoting user defined objects | p. 333 |
Defining a Cast Operator | p. 334 |
Defining the rules for implicit conversions | p. 335 |
Overloading the Assignment Operator | p. 337 |
Overloading the Assignment Operator Is Critical | p. 337 |
Finding Out How to Overload the Assignment Operator | p. 338 |
Creating shallow copies is a deep problem | p. 340 |
Going to C++ member-by-member | p. 341 |
Returning from over-C's assignments | p. 342 |
Providing member protection | p. 342 |
Using Stream I/O | p. 345 |
Diving into Stream I/O | p. 345 |
Examining the fstream Subclasses | p. 348 |
Using the strstream Subclasses | p. 351 |
Manipulating Manipulators | p. 353 |
Writing Custom Inserters | p. 356 |
Generating Smart Inserters | p. 359 |
Handling Errors--Exceptions | p. 361 |
Justifying a New Error Mechanism? | p. 362 |
Examining the Exception Mechanism | p. 364 |
What Kinds of Things Can I Throw? | p. 366 |
Inheriting Multiple Inheritance | p. 369 |
Describing the Multiple Inheritance Mechanism | p. 369 |
Straightening Out Inheritance Ambiguities | p. 371 |
Adding Virtual Inheritance | p. 372 |
Constructing the Objects of Multiple Inheritance | p. 377 |
Voicing a Contrary Opinion | p. 377 |
The Part of Tens | p. 381 |
Ten Ways to Avoid Adding Bugs to Your Program | p. 383 |
Enabling All Warnings and Error Messages | p. 383 |
Insisting on Clean Compiles | p. 384 |
Adopting a Clear and Consistent Coding Style | p. 384 |
Limiting the Visibility | p. 385 |
Commenting Your Code While You Write It | p. 386 |
Single-Stepping Every Path at Least Once | p. 387 |
Avoid Overloading Operators | p. 387 |
Heap Handling | p. 388 |
Using Exceptions to Handle Errors | p. 388 |
Avoiding Multiple Inheritance | p. 388 |
The Ten Most Important Microsoft Visual C++ Compiler Settings | p. 389 |
Generating a Command Line Program | p. 390 |
Changing Project Settings | p. 390 |
Choosing General Settings | p. 391 |
Selecting Settings for Debug | p. 392 |
Choosing General Options for C/C++ | p. 393 |
Controlling C++ Language Settings | p. 394 |
Choosing Code Generation Settings | p. 395 |
Customizing with the Code Generation Window | p. 396 |
Controlling Compile Optimizations | p. 396 |
Selecting Precompiled Headers | p. 397 |
About the CD-ROM | p. 399 |
System Requirements | p. 399 |
Using the CD with Microsoft Windows | p. 399 |
What You'll Find | p. 400 |
If You've Got Problems (Of the CD Kind) | p. 401 |
Glossary | p. 403 |
Index | p. 407 |
IDG Books Worldwide End-User License Agreement | p. 426 |
GNU General Public License | p. 428 |
Installation Instructions | p. 433 |
Book Registration Information | |
Table of Contents provided by Syndetics. All Rights Reserved. |
The New copy of this book will include any supplemental materials advertised. Please check the title of the book to determine if it should include any access cards, study guides, lab manuals, CDs, etc.
The Used, Rental and eBook copies of this book are not guaranteed to include any supplemental materials. Typically, only the book itself is included. This is true even if the title states it includes any access cards, study guides, lab manuals, CDs, etc.