Seasoned C++ programmer Matthew Telles shows developers at any level of experience how to save hours by improving, refactoring, and debugging their code Some of the techniques covered include mastering asserts, creating a complete class, hiding a method of a base class, freeing blocks of memory, imp
C++ Timesaving Techniques For Dummies
โ Scribed by Matthew Telles
- Publisher
- Wiley
- Year
- 2005
- Tongue
- English
- Leaves
- 507
- Series
- For dummies
- Edition
- 1
- Category
- Library
No coin nor oath required. For personal study only.
โฆ Synopsis
- Seasoned C++ programmer Matthew Telles shows developers at any level of experience how to save hours by improving, refactoring, and debugging their code
- Some of the techniques covered include mastering asserts, creating a complete class, hiding a method of a base class, freeing blocks of memory, implementing a simple locking mechanism, creating debugging macros, checking for errors at run-time, finding and fixing memory leaks, and reducing code complexity
- The easy-to-follow, two-column Timesaving Techniques format makes mastering each timesaver a snap
- C++ is one of today's most widely used programming languages, with compilers offered by Microsoft, Borland, and Code Warrior
- This book is the perfect companion to C++ For Dummies , Fifth Edition (0-7645-6852-3)
โฆ Table of Contents
Team DDU......Page 1
Contents......Page 16
Introduction......Page 22
Conventions Used in This Book......Page 23
Part V: Arrays and Templates......Page 24
Icons Used in This Book......Page 25
Part I: Streamlining the Means and Mechanics of OOP......Page 26
Creating and Implementing an Encapsulated Class......Page 28
Making Updates to an Encapsulated Class......Page 31
Creating a Mailing-List Application......Page 33
Testing the Mailing-List Application......Page 38
Technique 3: Customizing a Class with Virtual Functions......Page 40
Customizing a Class with Polymorphism......Page 41
Testing the Virtual Function Code......Page 42
Why Do the Destructors Work?......Page 43
Technique 4: Inheriting Data and Functionality......Page 44
Implementing a ConfigurationFile Class......Page 45
Delayed Construction......Page 48
Technique 5: Separating Rules and Data from Code......Page 51
The cDate Class......Page 52
Testing the cDate Class......Page 56
Part II: Working with the Pre-Processor......Page 58
Creating the Header File......Page 60
Testing the Header File......Page 61
The Assert Problem......Page 63
Fixing the Assert Problem......Page 65
Technique 8: Using const Instead of #define......Page 66
Using the const Construct......Page 67
Fixing the Errors......Page 68
Technique 9: Macros and Why Not to Use Them......Page 69
Initiating a Function with a String Macro - Almost......Page 70
Fixing What Went Wrong with the Macro......Page 71
Using Macros Appropriately......Page 72
Using the sizeof Function......Page 73
Evaluating the Results......Page 75
Using sizeof with Pointers......Page 76
Part III: Types......Page 78
Technique 11: Creating Your Own Basic Types......Page 80
Implementing the Range Class......Page 81
Testing the Range Class......Page 83
Technique 12: Creating Your Own Types......Page 84
Creating the Matrix Class......Page 85
Matrix Operations......Page 86
Multiplying a Matrix by a Scalar Value......Page 87
Multiplying a Matrix by Scalar Values, Take 2......Page 88
Testing the Matrix Class......Page 89
Technique 13: Using Enumerations......Page 91
Implementing the Enumeration Class......Page 92
Testing the Enumeration Class......Page 93
Technique 14: Creating and Using Structures......Page 94
Implementing Structures......Page 95
Interpreting the Output......Page 96
Defining Constants......Page 98
Implementing Constant Variables......Page 99
Testing the Constant Application......Page 101
Using the const Keyword......Page 102
Technique 16: Scoping Your Variables......Page 103
Illustrating Scope......Page 104
Interpreting the Output......Page 105
Technique 17: Using Namespaces......Page 106
Creating a Namespace Application......Page 107
Testing the Namespace Application......Page 109
Technique 18: Fixing Breaks with Casts......Page 111
Using Casts......Page 112
Addressing the Compiler Problems......Page 114
Testing the Changes......Page 115
Technique 19: Using Pointers to Member Functions......Page 117
Implementing Member-Function Pointers......Page 118
Testing the Member Pointer Code......Page 120
Technique 20: Defining Default Arguments for Your Functions and Methods......Page 122
Customizing the Functions We Didn't Write......Page 123
Customizing Functions We Wrote Ourselves......Page 124
Testing the Default Code......Page 126
Fixing the Problem......Page 127
Part IV: Classes......Page 128
Technique 21: Creating a Complete Class......Page 130
Creating a Complete Class Template......Page 131
Testing the Complete Class......Page 134
Technique 22: Using Virtual Inheritance......Page 137
Implementing Virtual Inheritance......Page 139
Correcting the Code......Page 140
Technique 23: Creating Overloaded Operators......Page 141
Rules for Creating Overloaded Operators......Page 142
Using Overloaded Operators......Page 143
Testing the MyString Class......Page 146
Technique 24: Defining Your Own new and delete Handlers......Page 149
Overloading new and delete Handlers......Page 150
Testing the Memory Allocation Tracker......Page 154
Technique 25: Implementing Properties......Page 157
Implementing Properties......Page 158
Testing the Property Class......Page 161
Implementing Data Validation with Classes......Page 163
Testing Your SSN Validator Class......Page 167
Technique 27: Building a Date Class......Page 170
Creating the Date Class......Page 171
Implementing the Date Functionality......Page 173
Testing the Date Class......Page 180
Some Final Thoughts on the Date Class......Page 182
Technique 28: Overriding Functionality with Virtual Methods......Page 183
Creating a Factory Class......Page 184
Testing the Factory......Page 187
Enhancing the Manager Class......Page 188
Technique 29: Using Mix-In Classes......Page 189
Implementing Mix-In Classes......Page 190
Compiling and Testing Your Mix-In Class......Page 191
Part V: Arrays and Templates......Page 194
Technique 30: Creating a Simple Template Class......Page 196
Technique 31: Extending a Template Class......Page 200
Implementing Template Classes in Code......Page 201
Testing the Template Classes......Page 203
Using Non-class Template Arguments......Page 205
Implementing Function Templates......Page 207
Creating Method Templates......Page 210
Using the Vector Class......Page 213
Creating the String Array Class......Page 217
Working with Vector Algorithms......Page 221
Examining Allocations of Arrays and Pointers......Page 225
Technique 37: Creating Arrays of Objects......Page 230
Creating an Array of Heterogeneous Objects......Page 234
Technique 39: Implementing a Spreadsheet......Page 237
Creating the Column Class......Page 238
Creating the Row Class......Page 239
Creating the Spreadsheet Class......Page 240
Testing Your Spreadsheet......Page 242
Part VI: Input and Output......Page 244
Working with Streams......Page 246
Technique 41: Reading In and Processing Files......Page 249
Testing the File-Reading Code......Page 253
Creating the Test File......Page 254
Reading Delimited Files......Page 255
Testing the Code......Page 259
Technique 43: Writing Your Objects as XML......Page 261
Creating the XML Writer......Page 262
Testing the XML Writer......Page 264
Technique 44: Removing White Space from Input......Page 267
Technique 45: Creating a Configuration File......Page 271
Creating the Configuration-File Class......Page 272
Testing the Configuration-File Class......Page 281
Part VII: Using the Built-In Functionality......Page 284
Technique 46: Creating an Internationalization Class......Page 286
Building the Language Files......Page 287
Reading the International File......Page 293
Testing the String Reader......Page 298
Creating a Translator Class......Page 300
Testing the Translator Class......Page 302
Creating a Virtual File Class......Page 304
Testing the Virtual File Class......Page 310
Improving Your Virtual File Class......Page 311
Technique 49: Using Iterators for Your Collections......Page 312
Technique 50: Overriding the Allocator for a Collection Class......Page 318
Creating a Custom Memory Allocator......Page 319
Using the auto_ptr Class......Page 324
Creating a Memory Safe Buffer Class......Page 328
Throwing and Logging Exceptions......Page 333
Dealing with Unhandled Exceptions......Page 338
Re-throwing Exceptions......Page 340
Technique 54: Enforcing Return Codes......Page 344
Technique 55: Using Wildcards......Page 351
Creating the Wildcard Matching Class......Page 352
Testing the Wildcard Matching Class......Page 354
Part VIII: Utilities......Page 356
Technique 56: Encoding and Decoding Data for the Web......Page 358
Creating the URL Codec Class......Page 359
Testing the URL Codec Class......Page 361
Technique 57: Encrypting and Decrypting Strings......Page 364
Implementing the Rot13 Algorithm......Page 365
Testing the Rot13 Algorithm......Page 366
Implementing the XOR Algorithm......Page 367
Testing the XOR Algorithm......Page 368
Technique 58: Converting the Case of a String......Page 370
Implementing the transform Function to Convert Strings......Page 371
Testing the String Conversions......Page 372
Technique 59: Implementing a Serialization Interface......Page 375
Implementing the Serialization Interface......Page 376
Testing the Serialization Interface......Page 379
Technique 60: Creating a Generic Buffer Class......Page 381
Creating the Buffer Class......Page 382
Testing the Buffer Class......Page 385
Technique 61: Opening a File Using Multiple Paths......Page 387
Creating the Multiple-Search-Path Class......Page 388
Testing the Multiple-Search-Path Class......Page 390
Part IX: Debugging C++ Applications......Page 394
Technique 62: Building Tracing into Your Applications......Page 396
Implementing the Flow Trace Class......Page 397
Testing the Flow Trace System......Page 400
Adding in Tracing After the Fact......Page 401
The assert Macro......Page 408
Logging......Page 410
Testing the Logger Class......Page 411
Design by Contract......Page 413
Technique 64: Debugging Overloaded Methods......Page 420
Adding Logging to the Application......Page 422
Part X: The Scary (or Fun!) Stuff......Page 426
Making Functions Inline......Page 428
Avoiding Temporary Objects......Page 429
Passing Objects by Reference......Page 431
Postponing Variable Declarations......Page 433
Choosing Initialization Instead of Assignment......Page 434
Learning How Code Operates......Page 437
Testing the Properties Class......Page 439
Technique 67: Creating a Simple Locking Mechanism......Page 441
Creating the Locking Mechanism......Page 442
Testing the Locking Mechanism......Page 443
Technique 68: Creating and Using Guardian Classes......Page 446
Creating the File-Guardian Class......Page 447
Testing the File-Guardian Class......Page 451
Technique 69: Working with Complex Numbers......Page 453
Implementing the Complex Class......Page 454
Testing the Complex Number Class......Page 457
Technique 70: Converting Numbers to Words......Page 460
Creating the Conversion Code......Page 461
Testing the Conversion Code......Page 467
A Sample Program......Page 468
Componentizing......Page 470
Restructuring......Page 472
Specialization......Page 473
Index......Page 476
๐ SIMILAR VOLUMES
Seasoned C++ programmer Matthew Telles shows developers at any level of experience how to save hours by improving, refactoring, and debugging their code Some of the techniques covered include mastering asserts, creating a complete class, hiding a method of a base class, freeing blocks of memory, imp
* Seasoned C++ programmer Matthew Telles shows developers at any level of experience how to save hours by improving, refactoring, and debugging their code* Some of the techniques covered include mastering asserts, creating a complete class, hiding a method of a base class, freeing blocks of memory,
<ul> <li>Seasoned C++ programmer Matthew Telles shows developers at any level of experience how to save hours by improving, refactoring, and debugging their code <li>Some of the techniques covered include mastering asserts, creating a complete class, hiding a method of a base class, freein
Most books cover the syntax of the language. This book covers some interesting tips on how to use it effectively. In particular, I was drawn to this book for its example of a class factory. Not a topic covered in most books.