Anda di halaman 1dari 10

Contents

LIST OF FIGURES A N D TABLES

Xlll

FOREWORD PROLOGUE

xvn
xix

Background Project Management


PREFACE

xix xxi xxiii xxiii xxiii xxiv xxv xxv xxv xxv xxv xxvii 1 1 2 3 6 7 8 8 11 12 12 13 17
17

Introduction Audience Flow Standard C++ Class Libraries Examples Further Reading Errata Notation Acknowledgments
1 OBJECT-ORIENTED DESIGN

Introduction 1.1 Definition of an Object 1.2 Object Model 1.2.1 Modularity .2.2 Encapsulation .2.3 Abstraction .2.4 Design Hierarchy .2.5 Concurrency .2.6 Persistence .2.7 Typing 1.3 Relationships among Objects 1.4 Notation 1.4.1 Booch-93 Notation 1.4.2 Function Hierarchy Summary Glossary

25 25 27
VII

viii

Contents

OBJECT MODEL DEVELOPMENT

29

Introduction 2.1 Organizational Infrastructure 2.2 Requirements Definition Phase 2.3 Analysis and Design Phase 2.3.1 Macro-Development Process 2.3.2 Micro-Development Process 2.4 Implementation Phase 2.5 Test Phase Summary Glossary
3 OBJECT-ORIENTED PROGRAMMING A N D C++

29 30 32 34 35 44 52 53 54 55
57

Introduction 3.1 Object-Oriented Programming 3.2 Class 3.2.1 Access Levels 3.2.2 Data Members 3.2.3 Member Functions 3.2.4 Design Interface 3.3 Objects 3.3.1 Object Construction 3.3.2 Object Destruction 3.3.3 Object Manipulation 3.4 Object Model 3.5 Inheritance 3.6 Templates Summary Glossary
4 BASICS OF C++

57 57 58 60 62 63 67 68 68 72 75 77 79 82 84 86
87

Introduction 4.1 Stream I/O Class Library 4.2 Comments 4.3 Class Definition 4.4 Constants 4.5 Function Overloading 4.6 Function Parameters 4.6.1 Call-by-Value 4.6.2 Call-by-Address 4.6.3 Call-by-Reference 4.7 Dynamic Memory Allocation 4.8 Object Visibility and Lifetime in C++ 4.9 Namespace 4.10 C++ Cast Constructs Summary Glossary

87 89 92 93 95 98 101 101 104 106 109 110 114 1 \% 123 124

Contents

}x

CLASS

127

Introduction 5.1 Class Data Members 5.1.1 Regular Data Members 5.1.2 Static Data Members 5.2 Class Member Functions 5.2.1 Class Constructor Functions 5.2.2 Class Destructor Functions 5.2.3 Compiler-Generated Member Functions 5.2.4 Regular Member Functions 5.2.5 Static Member Functions 5 3 Friend Classes Summary Glossary
6 FUNCTIONS

] 27 128 128 131 137 137 147 149 152 154 159 160 162
163

Introduction 6.1 Inline Functions 6.2 Operator Overloading 6.2.1 Implicit Conversion 6.2.2 Binary Operators 6.2.3 Unary Operators 6.2.4 Operator/Assignment 6.2.5 Operator Overloading Restrictions 6.2.6 Guidelines for Operator Overloading 6.3 Friend Function 6.4 Standard C++Class Libraries 6.4.1 Stream I/O Class Library 6.4.2 Complex Class Library 6.4.3 String Class Library Summary Glossary
7 DYNAMIC MEMORY ALLOCATION

163 165 168 176 178 181 182 184 186 187 193 193 194 195 196 197
199

Introduction 7.1 Overview of Dynamic Memory Allocation 7.2 Dynamic Memory Allocation Library 7.3 C++ and Dynamic Memory Allocation 7.3.1 Memory Allocation 7.3.2 Memory Deallocation 7.4 Dynamic Allocation Failure and Recovery 7.5 Garbage Collection 7.6 Custom Memory Management 7.6.1 Overloaded New Operator 7.6.2 Overloaded Delete Operator 7.6.3 User-Defined Error Handling 7.6.4 Custom Array Allocation and Deallocation 7.6.5 General Notes Summary Glossary

199 199 202 204 205 214 216 218 219 227 228 229 229 231 231 231

Contents

ERROR DETECTION A N D RECOVERY

233

Introduction 8.1 Serial I/O Communication Class Library Overview 8.2 Serial I/O Exceptions 8.3 Error Capturing 8.4 Class Interfaces 8.5 Error Detection and Reporting 8.6 Error Recovery 8.7 Partial Error Recovery 8.8 Unexpected Exceptions 8.9 Standard Exception Library 8.9.1 Bad Exceptions 8.9.2 Logical Exceptions 8.9.3 Run Time Exceptions 8.9.4 Dynamic Allocation Exceptions 8.9.5 Data Type Exceptions Summary Glossary
B INHERITANCE

233 234 237 243 246 248 254 256 258 258 258 258 259 259 261 261 262
263

Introduction 9.1 Purpose of Inheritance 9.2 Inheritance is-a Relationship 9.3 Inheritance in C++ 9.3.1 Base Class 9.3.2 Protected Design Interface 9.3.3 Derived Class 9.4 Types of Inheritance 9.4.1 Public Inheritance 9.4.2 Protected Inheritance 9.4.3 Private Inheritance 9.5 Inheritance Access Level Summary 9.6 Object Construction 9.7 Object Destruction 9.8 Dominance 9.9 Feature Mapping 9.10 Data Conversion 9.11 Multiple Inheritance 9.12 Virtual Base Class 9.13 Object-Oriented Considerations 9.14 Stream I/O Class Hierarchy Summary Glossary
10 POLYMORPHISM

263 263 265 266 266 271 273 276 276 280 281 282 283 284 284 285 286 290 291 294 295 297 299
301

Introduction 10.1 Polymorphic Behavior 10.2 Virtual Functions 10.3 Dynamic Binding 10.4 Abstract Class

30 [ 301 305 313 31g

Contents

xi

10.5 Polymorphism and Class Management 10.6 Dynamic Casting 10.7 Run-Time Type Identification 10.8 Application of Design Hierarchy to Error Handling 10.9 Object-Oriented Programming Considerations Summary Glossary
11 TEMPLATES

321 324 326 330 332 334 335


337

Introduction 11.1 Template Functions 11.2 Template Classes 11.2.1 Template Class Definition 11.2.2 Template Class Implementation 11.2.3 Template Class Usage 11.3 Templates and Design Hierarchy 11.4 Standard Template Library 11.4.1 Structure of the Library 11A 2 Design Concepts Summary Glossary
12 DISTRIBUTED OBJECTS

337 338 342 346 348 350 352 358 358 362 362 363
365

Introduction 12.1 Common Object Request Broker Architecture (CORBA) 12.1.1 Interface Definition Language (IDL) 12.1.2 Object Request Broker (ORB) 12.1.3 Common Object Services 12.1.4 Common Facilities 12.2 Distributed Object 12.2.1 Object Construction 12.2.2 Object Interaction 12.2.3 Object Destruction 12.2.4 Object Persistence 12.2.5 Object Concurrency 12.3 Design Issues Summary Glossary
13 INTRODUCTION TO JAVA

365 366 368 371 373 374 374 374 377 379 380 380 380 382 383
385

Introduction 13.1 Built-in Data Types 13.2 Package 13.3 Class Definition 13.4 Encapsulation 13.5 Abstraction 13.5.1 Constructor 13.5.2 Regular Methods 13.5.3 Static Methods 13.5.4 Destructor

385 386 389 391 393 393 393 394 397 397

xii

Contents

13.6 Design Hierarchy 13.7 Concurrency 13.8 Exceptions 13.9 Interfaces 13.10 Java Environment 13.11 Java Library Summary Glossary
14 UNIFIED MODELING LANGUAGE

397 401 403 404 405 406 407 407


409

Introduction 14.1 Static Model 14.1.1 Deployment Diagram 14.1.2 Component Diagram 14.1.3 Class Diagram 14.1.4 Operation Specification 14.2 Dynamic Model 14.2.1 State Diagram 14.2.2 Sequence Diagram 14.2.3 Collaboration Diagram 14.2.4 Use-Case Diagram Summary Glossary
REFERENCES

409 409 410 411 413 418 419 420 422 423 425 425 425
427

Textbooks Publications Standards Miscellaneous

427 428 428 428

List of Figures and Tables

FIGURE 1.1 FIGURE 1.2 FIGURE 1.3 FIGURE 1.4 FIGURE 1.5 FIGURE 1.6 FIGURE 1.7 FIGURE 1.8 FIGURE 1.9 FIGURE 1.10 FIGURE 1.11 FIGURE 1.12 FIGURE 1.13 FIGURE 1.14 FIGURE 1.15 FIGURE 1.16 FIGURE 1.17 FIGURE 1.18 FIGURE 1.19 FIGURE 1.20 FIGURE 1.21 FIGURE 1.22 FIGURE 1.23 FIGURE 1.24 FIGURE:U FIGURE:1.2 FIGURE I>.3 FIGURE:>.4 FIGURE:>.5 FIGURE 2.6 FIGURE 2.7 FIGURE:>.8 FIGURE:1.9 FIGURE 2 >.10 FIGURE:IM FIGURE S l.\2 FIGURE:U 3

Iterative design process Modem class Modem state transition diagram Class and object PC class diagram PC class diagram Disk class diagram Disk class diagram Disk class diagram Aircraft repair maintenance data system GOLD software user interface Car/person class diagram Radar class diagram Printer class diagram Aircraft hierarchy class diagram Improper car class diagram Booch-93 Diagrams GOLD system module diagram Spare part list category diagram F-14 fighter plane class diagram Modem state transition diagram Software development group interaction diagram Software development group object diagram Serial stream class function hierarchy (data transmission) System development overview Object-oriented software life cycle Software development organizational overview Analysis and design phase overview Banking system module diagram (preliminary) Requirements traceability matrix (RTM) sample Facsimile transmission data flow block diagram CCITT group 3 facsimile data encoding block diagram CCITT group 3 facsimile data transmission format FAX system module diagram Facsimile transmission FAX system development cycles Relative cost of corrections in the software life cycle

2 2 4 5 6 7 8 9 10 11 13 14 14 15 16 17 18 19 20 21 22 23 24 26 30 31 32 34 35 36 37 38 39 40 41 43 44

XIII

XIV

List of Figures

FIGURE 2.14 FIGURE 2.15 FIGURE 2.16 FIGURE 2.17 FIGURE 2.18 FIGURE 3.1 FIGURE 3.2 FIGURE 3.3 FIGURE 3.4 FIGURE 3.5 FIGURE 3.6 FIGURE 3.7 FIGURE 3.8 FIGURE 3.9 FIGURE 3.10 FIGURE 3.11 FIGURE 4.1 FIGURE 4.2 FIGURE 4.3 FIGURE 4.4 FIGURE 4.5 FIGURE 4.6 FIGURE 4.7 FIGURE 4.8 FIGURE 4.9 FIGURE 4.10 FIGURE 4.11 FIGURE 4.12 FIGURE 4.13 FIGURE 4.14 FIGURE 5.1 FIGURE 5.2 FIGURE 5.3 FIGURE 5.4 FIGURE 5.5 FIGURE 5.6 FIGURE 5.7 FIGURE 5.8 FIGURE 5.9 FIGURE 5.10 FIGURE 5.11 FIGURE 5.12 FIGURE 5.13 FIGURE 6.1 FIGURE 6.2 FIGURE 6.3 FIGURE 6.4 FIGURE 6.5 FIGURE 6.6 FIGURE 6.7 FIGURE 7.1 FIGURE 7.2

Scanner class diagram Scanner state transition diagram Scanner object di agram Account class diagram Layered test methodology Account class diagram Access levels Account Class Memory Layout ATM withdrawal interaction diagram Construction of account objects Bank account state transition diagram Bank account system high level module diagram Account class diagram ATM and account class category diagram Savings account class Linked-list class diagram C++ venn diagram Circle data representation Circle class diagram CIRCLE.H header file CIRCLE.CPP source file Circle object creation interaction diagram Constant variable definitions Point data representation Access levels Point::add () parameter call-by-value Data access through pointers Point:: add() parameter access Data access through pointers IEEE floating point representation House floor plan and its instances Savings class diagram Savings class representations and architectures Savings object default copy (shallow copy) Static class member Savings class diagram Savings object diagram Name class representation and architecture Construction of a name object Copy construction of a name object Shallow copy of a name object Savings class diagram OOP and C++ function classification Types of functions in C++ Complex number representation Deep copy for a name object Complex addition Complex class function hierarchy Examples of container classes Complex class diagram C++ Object mapping in the memory space Dynamic memory allocation

45 46 48 49 53 59 62 62 71 72

76 77 78 79 81 84 87 88 89 90 91 96 99 101 103 104 105 106 110 120 128 129 130 132 134
135

136
138

141 145 151


160 161

163 164 170 174


175

186
188 200

201

List of Figures

xv
Memory fragmentation Dynamic memory reallocation Grade object dynamic memory allocation Construction of a name object Deep copy for a name object Array of name objects Memory unfragmentation Dynamic memory allocation with garbage collection Custom memory management Embedded systems serial communication block diagram Serial I/O class diagram PC communication block diagram Communication module category diagram Serial I/O communication class diagram Full-duplex serial communication block diagram Serial stream state transition diagram Data transmission object diagram Data receive object diagram Circular buffer block diagram Communication timeout failure exception handling Remote file retrieval function hierarchy Serial stream access by interrupt request handler Standard exception class diagram Inheritance Account class diagram File class diagrams File class representation and architecture File class diagram Text file object memory layout File class diagram Text file object construction and destruction Base and derived object conversions (public inheritence) Text file pointer convers Money market class diagram and memory layout Money market class diagram and memory layout I/O stream library class diagram User defined window stream class diagram diagram Shape class design hierarchy. Shape class hierarchy. Application software and shape classes interaction Circle class diagram Circle object creation interaction diagram Rectangle and square class diagram Square object creation interaction diagram Circle class virtual table overview Square class virtual-table overview Shape class design hierarchy An example of a complex class design hierarchy RTTI class diagram Circle object creation interaction diagram Circle object creation interaction diagram Custom exception class diagram 201 203 206 207 213 215 219 220 221 222 224 234 235 236 236 237 238 239 242 250 251 253 259 264 265 267 268 272 274 277 284 287 288 292 293 297 298 302 303 304 307 309 312 314 315 316 320 326 327 329 331 333

FIGURE 7.3 FIGURE 7.4 FIGURE 7.5 FIGURE 7.6 FIGURE 7.7 FIGURE 7.8 FIGURE 7.9 FIGURE 7.10 FIGURE 7. II FIGURE 7.12 FIGURE 7.13 FIGURE 8.1 FIGURE 8.2 FIGURE 8.3 FIGURE 8.4 FIGURE 8.5 FIGURE 8.6 FIGURE 8.7 FIGURE 8.8 FIGURE 8.9 FIGURE 8.10 FIGURE8.il FIGURE 8.12 FIGURE 9.1 FIGURE 9.2 FIGURE 9.3 FIGURE 9.4 FIGURE 9.5 FIGURE 9.6 FIGURE 9.7 FIGURE 9.8 FIGURE 9.9 FIGURE 9.10 FIGURE9.il FIGURE 9.12 FIGURE 9.13 FIGURE 9.14 FIGURE 10.1 FIGURE 10.2 FIGURE 10.3 FIGURE 10.4 FIGURE 10.5 FIGURE 10.6 FIGURE 10.7 FIGURE 10.8 FIGURE 10.9 FIGURE 10.10 FIGURE 10.11 FIGURE 10.12 FIGURE 10.13 FIGURE 10.14 FIGURE 10.15

xvi

List of Figures

FIGURE 10.16 FIGURE 11.1 FIGURE 11.2 FIGURE 11.3 FIGURE 11.4 FIGURE 11.5 FIGURE 11.6 FIGURE 11.7 FIGURE 11.8 FIGURE 11.9 FIGURE 12.1 FIGURE 12.2 FIGURE 12.3 FIGURE 12.4 FIGURE 12.5 FIGURE 12.6 FIGURE 12.7 FIGURE 12.8 FIGURE 13.1 FIGURE 13.2 FIGURE 13.3 FIGURE 13.4 FIGURE 14.1 FIGURE 14.2 FIGURE 14.3 FIGURE 14.4 FIGURE 14.5 FIGURE 14.6 FIGURE 14.7 FIGURE 14.8 FIGURE 14.9 FIGURE 14.10 FIGURE 14.11 FIGURE 14.12

Shape class design hierarchy Container classes CAD user interface class diagram Container class architecture Array class diagram Array exception object memory layout Array block diagram Array class diagram Linked list object diagram Linked list class diagram Bank account system Common object request broker architecture (CORBA) components ATM and savings interaction ATM and savings interaction via an ORB Savings object creation and interaction Bank accounts factory class diagram Distributed object block diagram Persistent object services (POS) block diagram Shape class design hierarchy Thread class diagram List exception class diagram Thread class diagram Bank account system platform diagram Bank account system high-level component diagram Automated teller machine (ATM) component diagram (preliminary) Account class diagram Bank Accounts category class diagram Automated teller machine (ATM) component diagram (preliminary) Linked List class diagram CAD class diagram Account class state diagram Account class state diagram ATM withdrawal sequence diagram Account collaboration diagram

334 338 339 340 343 344 348 351 353 354 366 367 371 372 375 376 378 381 390 402 404 406 410 411 412 414 416 417 418 419 420 421 423 424

TABLE 3.1 TABLE 4.1 TABLE 6.1 TABLE 6.2 TABLE 9.1 TABLE 9.2 TABLE 11.1 TABLE 11.2 TABLE 13.1 TABLE 13.2

Access Levels and Clients Object Visibility and Lifetime C++ Operators Operator Function Table Usage Base Class Members Access Level Visibility of a Base Class to the Clients of the Derived Class Standard Template Library Header File Iterator Classes Java Built-in Data Types Java's Access Levels

85 112 169 197 282 298 358 361 386 393

Anda mungkin juga menyukai