Advanced C++: Programming Styles And Idioms

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

Author(s): James Coplien
Publisher: Addison-Wesley
Year: 1992

Language: English
Commentary: this is the correct book, not the spammy CHM
Pages: 545

Contents xi
Preface v
Contents XI
@=26
1: Introduction 1
...1.1 C++: An Evolving Language 1
...1.2 Handling Complexity with Idioms 2
...1.3 Objects for the Nineties 4
...1.4 Design and Language 5
...References 6
2: Data Abstraction and Abstract Data Types 7
...2.1 Classes 8
...2.2 Object Inversion 11
...2.3 Constructors and Destructors 14
...2.4 Inline Functions 19
...2.5 Initialization of Static Data Members 21
...2.6 Static Member Functions 21
...2.7 Scoping and const 23
...2.8 Initialization Ordering of Global Objects, Constants, and Static Class Members 24
...2.9 Enforcement of const for Class Object Member Functions 26
...2.10 Pointers to Member Functions 29
...2.11 Program Organization Conventions 33
...Exercises 34
...References 36
3: Concrete Data Types 37
...3.1 The Orthodox Canonical Class Form 38
...3.2 Scoping and Access Control 45
...3.3 Overloading: Redefining the Semantics of Operators and Functions 48
...3.4 Type Conversion 54
...3.5 Reference Counting: Making Variables Use \l"Magic Memory\r" 58
...3.6 Operators new and delete 72
...3.7 Separating Initialization from Instantiation 79
...Exercises 82
...References 84
4: Inheritance 85
...4.1 Simple Inheritance 87
...4.2 Scoping and Access Control 94
...4.3 Constructors and Destructors 104
...4.4 Class Pointer Conversion 108
...4.5 Type Selector Fields 110
...Exercises 113
...References 115
5: Object-Oriented Programming 117
...5.1 C++ Run-Time Type Support: Virtual Functions 119
...5.2 Destructor Interaction and Virtual Destructors 127
...5.3 Virtual Functions and Scoping 128
...5.4 Pure Virtual Functions and Abstract Base Classes 131
...5.5 Envelope and Letter Classes 133
...5.6 Functors: Functions as Objects 165
...5.7 Multiple Inheritance 178
...5.8 The Inheritance Canonical Form 189
...Exercises 193
...Queue Iterator Example 195
...Simple Banking Account Application Classes 197
...References 199
6: Object-Oriented Design 201
...6.1 Types and Classes 202
...6.2 The Activities of Object-Oriented Design 207
...6.3 Object-Oriented Analysis and Domain Analysis 210
...6.4 Object and Class Relationships 213
...6.5 Subtyping, Inheritance, and Forwarding 222
...6.6 Rules of Thumb for Subtyping, Inheritance, and Independence 244
...Exercises 246
...References 247
7: Reuse and Objects 249
...7.1 All Analogies Break Down Somewhere 251
...7.2 Design Reuse 253
...7.3 Four Code Reuse Mechanisms 254
...7.4 Parameterized Types, or Templates 257
...7.5 Private Inheritance: Does Inheritance Support Reuse? 265
...7.6 Storage Reuse 269
...7.7 Interface Reuse: Variants 270
...7.8 Reuse, Inheritance, and Forwarding 272
...7.9 Architectural Alternatives for Source Reuse 273
...7.10 Generalizations on Reuse and Objects 276
...Exercises 277
...References 278
8: Programming with Exemplars in C++ 279
...8.1 An Example: Employee Exemplars 282
...8.2 Exemplars and Generic Constructors: The Exemplar Community Idiom 288
...8.3 Autonomous Generic Constructors 289
...8.4 Abstract Base Exemplars 293
...8.5 Toward a Frame Exemplar Idiom 295
...8.6 A Word About Notation 297
...8.7 Exemplars and Program Administration 299
...Exercises 301
...Exemplar-Based Simple Parser 302
...Frame-Based Exemplars 304
...References 306
9: Emulating Symbolic Language Styles in C++ 307
...9.1 Incremental C++ Development 309
...9.2 Symbolic Canonical Form 311
...9.3 An Example: A General Collection Class 323
...9.4 Code and Idioms to Support Incremental Loading 328
...9.5 Garbage Collection 339
...9.6 Primitive Type Encapsulation 349
...9.7 Multi-Methods under the Symbolic Idiom 349
...Exercises 354
...References 355
10: Dynamic Multiple Inheritance 357
...10.1 An Example: A Multi-Technology Window System 359
...10.2 Caveats 362
11: Systemic Issues 365
...11.1 Static System Design 366
...11.2 Dynamic System Design 375
...References 390
Appendix A: C in a C++ Environment 391
...A.1 Function Calls 391
...A.2 Function Parameters 392
...A.3 Function Prototypes 393
...A.4 Call-by-Reference Parameters 394
...A.5 Variable Number of Parameters 395
...A.6 Function Pointers 397
...A.7 The const Type Modifier 399
...A.8 Interfacing with C Code 401
...Exercises 414
...References 415
Appendix B: Shapes Program: C++ Code 417
Appendix C: Reference Return Values from Operators 431
Appendix D: Why Bitwise Copy Doesn't Work 435
...D.1 Why Member-by-Member Copy Isn't a Panacea 436
Appendix E: Symbolic Shapes 437
Appendix F: Block-Structured Programming in C++ 477
...F.1 What Is Block-Structured Programming? 477
...F.2 Basic Building Blocks for Structured C++ Programming 478
...F.3 An Alternative for Blocks with Deeply Nested Scopes 482
...F.4 Implementation Considerations 487
...Exercises 487
...Block-Structured Video Game Code 489
...References 493
Index 495