50
Programming with Objects A Comparative Presentation of Object-Oriented Programming with C++ and Java Avinash C. Kak Purdue University A Wiley-Interscience Publication JOHN WILEY & SONS, INC. NewYork / Chichester / Weinheim / Brisbane / Singapore / Toronto

Programming with Objects - College of Engineering - … with Objects A Comparative Presentation of Object-Oriented Programming with C++ and Java Avinash C. Kak Purdue University A

  • Upload
    voliem

  • View
    214

  • Download
    0

Embed Size (px)

Citation preview

Programming with Objects

A Comparative Presentation of

Object-Oriented Programming

with C++ and Java

Avinash C. KakPurdue University

A Wiley-Interscience Publication

JOHN WILEY & SONS, INC.

New York / Chichester / Weinheim / Brisbane / Singapore / Toronto

v

The errata and other information for this book isposted at

http://www.programming-with-objects.com

Preface

This book presents object-oriented programming with C++ and Java, which are to-day’s two dominant languages for such programming. The presentation format ismostly comparative, all the way from the basic language constructs to application-level issues dealing with graphics programming, network programming, and databaseprogramming. This book is intended for a reader who is well-conversant with theimportant features of C: pointers, strings, arrays, and structures.

The author strongly believes in the notion that, in addition to the syntax, it is essen-tial to also show a programming language through its applications to fully establish itsbeauty and power. Teaching a programming language divorced from its applications– not uncommon in many educational programs – would be like teaching Englishthrough just its grammar.

This book grew out of an attempt to meet a specific academic need for a compre-hensive educational program in object-oriented programming. We wanted a programthat would not be too indoctrinating with regard to any one style (or any one language,since language often dictates style) of object-oriented programming. While program-ming skill could have been taught by focusing on a single language, education in itslarger sense demanded that we provide a broader menu of styles and concepts. Theresult was what the reader sees in this book: An integrated presentation of C++ andJava. There is educational value in comparing and contrasting the two languages,from basic language constructs to how the languages are used in application-levelprogramming. Such comparisons may even inspire an enterprising student to thinkof new and more powerful object-oriented languages of the future. To further enhance

vii

viii PREFACE

the educational value of this comparative approach, this book also includes treatmentof simulated object-orientation in plain C, with GNOME/GTK+ presented as a majorexample of this approach.

This book is based on the philosophy that learning by comparison is very efficientand can be a lot of fun. Sometimes we find it easier to remember and learn things if wecan anchor our memory and comprehension in interesting differences and similaritiesbetween supposedly similar objects, structures, and situations. Learning C++ andJava together can exploit this aspect of human cognition. Students find it interestingto compare C++ and Java programming constructs for doing the same thing.

Teaching and learning C++ and Java together have some unique advantages. First,because both C++ and Java were born out of C, they have much in common at thelevel of basic language structures. Teaching these structures together saves time. Forexample, once the concept of a vector in C++ is made clear and some of the moreuseful functions associated with C++ vectors are elucidated, the discussion of the JavaArrayList takes hardly any time. The Java discussion consists mostly of pointing outthe Java functions that do the same thing as the previously discussed C++ functions.

Then there is also the unique process of learning by coding up a program in C++that does the same thing as a given program in Java, or vice versa. My experience isthat this approach enables the students to tackle more difficult projects in both C++and Java than would otherwise be the case under the time constraints of a course.

Learning two large languages together does have its down side. One can getconfused as to what feature belongs to which language. Fortunately, this difficultyis minimized by the modern programming practice of keeping one eye on the on-line documentation in one terminal window while programming in another terminalwindow. Both Java and C++ have become so large that it would be impossible foranyone to commit to memory all of the classes and all of the functions and attributesdefined for the classes. So even if one were not learning two languages simultaneously,one would still need to refer to documentation while writing programs.

The book contains more material than can be accommodated in a typical one-semester course. In my experience, the book works well for a sequence of twoback-to-back courses, the first focusing on the basic language constructs as presentedin the first fifteen chapters, and the second focusing on application- and design-levelissues. For the second course, I complement the material in the last five chapters witha book on design patterns.

It would be naive of me to assume that a manuscript as large as this would befree of errors. I’d be much grateful to the readers who would bring the errors tomy attention at

��������������� ���������. All corrections will be made available online at

��� �������������������� � � ���������� �!�� "��$#��%"���� , and the authors of the corrections will beduly acknowledged. The same applies to any slip-ups on my part in giving properattributions to authors. Where my example programs were inspired directly by whatI saw in other sources, I have acknowledged their authors in the “Credits and Sug-gestions for Further Reading” section at the end of each chapter.

PREFACE ix

The author will be glad to make available to the prospective instructors the solutionsto the homework problems.

Finally, the book should also be useful to those who are transitioning from C++ toJava, or vice versa.

Purdue University Avinash Kak

Acknowledgments

Whatever merit this book has should go in large measure to the stalwarts of the object-oriented programming movement, to those who created C++ and Java, and to thosewho have been the chief expositors of these two languages over the last several years(see the references at the end of the book).

This book would not have been possible without the help of the following people:

� Guilherme DeSouza, a man with insights that are as deep as they are broadand for whom Linux is a religion to which he has converted many, this authorincluded. Guilherme’s insights in multiprocessing and multithreading playedan important role in the revamping of Chapter 18.

� Elvia Suryadi, who can spot from a mile the slightest flaw in a logical argument,the minutest weakness in an explanation. Her constant feedback helped withthe cleanup of many sections of the book, too numerous to be listed hereindividually. The homework problems in Chapters 13 and 20 are by Elvia.

� Malcolm Slaney, with an uncanny eye for rigor and precision, for providingcritical feedback on the first five chapters.

� Carl Crawford, never a man to mince words,who insisted that my earlier versionof the front matter did not do justice to the rest of the book.

� Susan Gottschlich, with deep insights in the software development cycles ofindustry, for her careful reading and feedback of the first 11 chapters.

xi

xii

� Robert Cromwell, who has always had his ear to the ground for the latesthappenings in the world of software and hardware, for looking carefully at theC-related material in the book and suggesting improvements.

� Sarah Sellke, with many years of object-oriented software design and devel-opment experience for telecom and other applications, for her feedback onChapter 19.

� Christina Pavlopoulou,as a source of great help in the early stages of my puttingtogether this book.

� Prathima Venkatesan, who proofread and caught many errors in the draft copiesof Chapters 4, 5, 6, and 7.

� Bob Mulvey, for helping me better understand the various shortcomings asso-ciated with the use of

#�����!�� �–

�������!�� �macros for achieving multilevel return

in C.

� Brett Maden, for creating the final versions of the figures in Chapters 15 and17. He also contributed to the homework section of Chapter 17; the Qt andGNOME/GTK+ problems were supplied by him.

� Kheng Tan, for many of the final production figures for Chapters 14 and 16.Kheng also supplied the problems for the homework section of Chapter 14.

Thanks also go to the anonymous reviewers of the book; many of the comments Ireceived through the review process helped in the revision of much material. Of thepublisher reviews received nonanonymously, I wish to thank Simon Gray in particularfor catching many errors in Chapter 2, 8, 10, 14, and 19 and suggesting improvements.

Many additional sources of help and information that proved important to thewriting of this book are acknowledged near the end of each chapter in a section entitled“Credits and Suggestions for Further Reading,” or sometimes just “Suggestions forFurther Reading.” Occasionally, I have also used a footnote for the same purpose.

I am also grateful to Subhash Kak, whose powers of exposition border on thelyrical, for his many wonderful suggestions for smoothing out the text at variousplaces.

Finally, and most importantly, many thanks go to Carla for her loving friendship,support, and understanding, all things that give true meaning to life. Thanks alsogo to Carla for her direct contributions to the book by way of critical reading of itsvarious sections.

A.C.K.

Contents in Brief

1 Why OO Programming – Some Parallels with Things atLarge 1

2 Baby Steps 5

3 The Notion of a Class and Some Other Key Ideas 29

4 Strings 107

5 Using the Container Classes 147

6 The Primitive Types and Their Input/Output 211

7 Declarations, Definitions, and Initializations 287

8 Object Reference and Memory Allocation 339

9 Functions and Methods 353

xiii

xiv CONTENTS IN BRIEF

10 Handling Exceptions 389

11 Classes, The Rest of the Story 423

12 Overloading Operators in C++ 513

13 Generics and Templates 569

14 Modeling Diagrams for OO Programs 607

15 Extending Classes 637

16 Multiple Inheritance in C++ 743

17 OO for Graphical User Interfaces, A Tour of Three Toolkits811

18 Multithreaded Object-Oriented Programming 985

19 Network Programming 1049

20 Database Programming 1137

Contents

Preface vii

Acknowledgments xi

1 Why OO Programming – Some Parallels with Things atLarge 1

2 Baby Steps 52.1 Simple Programs: Summing an Array of Integers 62.2 Simple Programs: Terminal I/O 142.3 Simple Programs: File I/O 192.4 Suggestions for Further Reading 252.5 Homework 25

3 The Notion of a Class and Some Other Key Ideas 293.1 Defining a Class in C++ 323.2 Defining a Class in Java 373.3 Constructing Objects: Differences and Similarities

between C++ and Java 403.4 Defining a subclass in C++ 42

xv

xvi CONTENTS

3.4.1 A Small Demonstration of Polymorphism inC++ 44

3.5 Defining a Subclass in Java 463.5.1 A Small Demonstration of Polymorphism in

Java 483.6 Blocking Inheritance 493.7 Creating Print Representations for Objects 523.8 Object Destruction 543.9 Packages in Java 553.10 Namespaces in C++ 61

3.10.1 Using Declaration Versus Using Directive 643.10.2 Which Namespace Owns Names Imported

from Another Namespace? 653.10.3 Using Declarations and Directives Have Scope 663.10.4 Nesting Namespaces and Namespace Aliases 673.10.5 Unnamed Namespaces 693.10.6 Koenig Lookup for Unqualified Function

Names 703.11 Access Control for Class Members 713.12 Abstract Classes and Interfaces 733.13 Comparing Objects 773.14 Static Members of a Class 813.15 Template Classes 833.16 Nested Types 84

3.16.1 Nested Classes in C++ 843.16.2 Nested Classes in Java 89

3.17 Implementing OO Behavior in C Programs 943.18 Suggestions for Further Reading 1023.19 Homework 102

4 Strings 1074.1 Strings in C, A Brief Review 1084.2 Some Common Shortcomings of C-Style Strings 1114.3 C++ Strings 113

4.3.1 Constructing a C++ String Object 1134.3.2 Accessing Individual Characters 1144.3.3 String Comparison 1154.3.4 Joining Strings Together 1184.3.5 Searching for Substrings and Characters 120

CONTENTS xvii

4.3.6 Extracting Substrings 1224.3.7 Erasing and Inserting Substrings 1234.3.8 Size and Capacity 1244.3.9 Some Other String Functions 129

4.4 Strings in Java 1294.4.1 Constructing String and StringBuffer Objects 1314.4.2 Accessing Individual Characters 1344.4.3 String Comparison 1354.4.4 Joining Strings Together 1384.4.5 Searching and Replacing 1394.4.6 Erasing and Inserting Substrings 1414.4.7 Extracting Substrings 141

4.5 Suggestions for Further Reading 1424.6 Homework 142

5 Using the Container Classes 1475.1 Container Classes in C++ 148

5.1.1 Vector 1525.1.1.1 List Operations on Vectors 1595.1.1.2 Vector of Class Type Objects 1625.1.1.3 Using an Array to Initialize a Vector 166

5.1.2 Deque 1685.1.3 List 1705.1.4 Stack 1735.1.5 Queue 1755.1.6 Priority Queue 1765.1.7 Map 1785.1.8 Set 1805.1.9 Generic Algorithms 181

5.2 Containers in Java 1825.2.1 List 1855.2.2 Set 1895.2.3 Map 1915.2.4 Vector 1945.2.5 Algorithms for Java Containers 197

5.3 Credits and Suggestions for Further Reading 2015.4 Homework 201

xviii CONTENTS

6 The Primitive Types and Their Input/Output 2116.1 Tokens, Identifiers, and Variable Names 2116.2 Primitive Types in C++ and Java 2136.3 Boolean Type 2136.4 Character Types 2146.5 Integer Types 2206.6 Floating-point Types 2226.7 Type Conversion for the Primitive Types 223

6.7.1 Implicit Type Conversions in C++ 2246.7.2 Implicit Type Conversions in Java 2286.7.3 Explicit Type Conversion in C++ 2326.7.4 Explicit Type Conversion in Java 234

6.8 I/O Streams for C++ 2366.8.1 The C++ Stream Hierarchy 2376.8.2 Input–Output Operations for Character

Streams 2386.8.3 Input–Output Operations for Byte Streams 2466.8.4 Controlling the Format 2526.8.5 String Streams 257

6.9 I/O Streams for Java 2586.9.1 Writing Primitive Types 2596.9.2 Writing Strings 2676.9.3 Reading the Primitive Types 2716.9.4 Reading Strings 273

6.10 Suggestions for Further Reading 2746.11 Homework 275

7 Declarations, Definitions, and Initializations 2877.1 When is a Declaration also a Definition? 2877.2 Are the Defined Variables in C++ Initialized by

Default? 2907.3 Are the Defined Variables in Java Initialized by

Default? 2987.4 Declaration of Pointer Types in C++ 3027.5 Arrays of Pointers in C++ 3067.6 Declaring Multiple Names 3087.7 Scope of an Identifier in C++ 3097.8 Scope of an Identifier in Java 3117.9 Arrays and Their Initialization in C++ 312

CONTENTS xix

7.10 Arrays and their Initialization in Java 3187.10.1 A Java Array is an Object 3217.10.2 java.lang.Arrays Class for Sorting, Searching,

etc. 3227.11 Symbolic Constants 3267.12 Macros in C++ 3287.13 The Enumeration Type in C++ 3297.14 Suggestions for Further Reading 3347.15 Homework 334

8 Object Reference and Memory Allocation 3398.1 Object Reference in C++ 3398.2 Object Reference in Java 3428.3 Memory Allocation in C++ 3438.4 Memory Allocation in Java 3458.5 Structures in C++ 3468.6 Homework 349

9 Functions and Methods 3539.1 Function Declarations 3549.2 Passing Arguments in C++ 354

9.2.1 Passing a Primitive Type Argument by Value 3559.2.2 Passing a Primitive Type Argument by Pointer 3559.2.3 Passing a Primitive Type Argument by

Reference 3579.2.4 Passing a Class Type Argument by Value 3589.2.5 Passing a Class Type Argument by Pointer 3599.2.6 Passing a Class Type Argument by Reference 361

9.3 Passing Arguments in Java 3629.3.1 Passing a Primitive Type Argument 3629.3.2 Passing a Class Type Argument 362

9.4 C++ Functions Returning Reference Types 3679.5 Function Inlining in C++ 3689.6 Static Variables in C++ 3709.7 "���� # � Parameter and Return Type for C++ Functions 3719.8 � � � � � Parameters for Java Methods 3729.9 Array Arguments 3739.10 Overloading of Function Names and Constructors in

C++ 373

xx CONTENTS

9.11 Overload Resolution in Java 3789.12 Default Arguments for C++ Functions 3819.13 Pointers to Functions in C++ 3829.14 Suggestions for Further Reading 3849.15 Homework 385

10 Handling Exceptions 38910.1 #�����!���� – �������!�� � for Multi-Level Return in C 39010.2 Exception Handling in C++ 39410.3 Usage Patterns for Exception Handling in C++ 39710.4 Differences between C++ and Java for Exception

Handling 40510.5 Java Syntax for Exception Handling 40710.6 Usage Patterns for Exception Handling in Java 40910.7 Checked and Unchecked Exceptions in Java 41610.8 Suggestions for Further Reading 41710.9 Homework 418

11 Classes, The Rest of the Story 42311.1 Access Control of Constructors 423

11.1.1 Limiting the Number of Objects 42411.1.2 Limiting the Access to No-Arg Constructor in

C++ 42611.2 Can Multiple Constructors Help Each Other? 42911.3 Static Members in C++ 430

11.3.1 Initialization and Destruction of Static Objectsin C++ 437

11.4 Static Members in Java 43911.5 "���� #�� Member Functions in C++ 44311.6 Self-reference in C++ 44411.7 Self-reference in Java 44811.8 Destructors in C++ 45011.9 Object Destruction in Java 45511.10 Copy Constructors and Copy Assignment Operators

in C++ 46011.11 Semantics of the Assignment Operator in Java 46611.12 Object Cloning in Java 46711.13 Pointers to Class Members in C++ 47711.14 Interleaved Classes 481

CONTENTS xxi

11.15 A C++ Study of Interleaved Classes of ModerateComplexity 483

11.16 A Java Study of Interleaved Classes of ModerateComplexity 496

11.17 Suggestions for Further Reading 50411.18 Homework 504

12 Overloading Operators in C++ 51312.1 Operator Tokens and Operator Functions 51412.2 Global Overload Definitions for Operators 51512.3 Member-Function Overload Definitions for Operators 51712.4 Global Overload Definitions for Unary Operators 52012.5 Member-Function Overload Definitions for Unary

Operators 52112.6 A Case Study in Operator Overloading 52212.7 Smart Pointers: Overloading of Dereferencing

Operators 53612.8 Overloading Increment and Decrement Operators 54612.9 User-Defined Conversions 55112.10 Overloading of the ’()’ Operator 55512.11 Sorting Class Type Objects by Overloading the �

Operator 55812.12 Suggestions for Further Reading 56112.13 Homework 561

13 Generics and Templates 56913.1 Templatized Classes and Functions in C++ 572

13.1.1 A C++ Implementation of a Linked-ListProgram 572

13.1.2 A Parameterized Linked-List Program 57613.1.3 Function Templates in C++ 57713.1.4 Template Specialization 58013.1.5 General Syntax of a Template Declaration 583

13.2 Iterators Revisited 58513.2.1 Iterator Categories for Generic Algorithms 58513.2.2 How to Declare an Iterator 587

13.3 Parameterized Classes in Java 58813.3.1 Creating Your Own Parameterized Types in

Java 591

xxii CONTENTS

13.3.2 Parameterization of Methods 59613.3.3 Constraining the Parameters 599

13.4 Suggestions for Further Reading 60213.5 Homework 603

14 Modeling Diagrams for OO Programs 60714.1 Use Case Diagram 60814.2 Class Diagram 610

14.2.1 Association as a Relationship Between Classes 61214.2.2 Aggregation and Composition as Relationships

Between Classes 61314.2.3 Representing Attributes 61514.2.4 Representing Operations 61514.2.5 Stereotypes 616

14.3 Interaction Diagram 61714.3.1 Sequence Diagram 61714.3.2 Collaboration Diagram 623

14.4 Package Diagram 62414.5 Statechart Diagram 62614.6 Activity Diagram 63114.7 Credits and Suggestions for Further Reading 63314.8 Homework 635

15 Extending Classes 63715.1 Public Derivation of a Subclass in C++ 63715.2 Constructors for Derived Classes in C++ 64115.3 Copy Constructors for Derived Classes in C++ 64315.4 Assignment Operators for Derived Classes in C++ 64615.5 Overloading Operators for Derived Classes in C++ 64815.6 Destructors for Derived Classes in C++ 65315.7 Virtual Member Functions in C++ 659

15.7.1 Restrictions on Virtual Function Declarations 66415.7.2 Virtual Functions in Multilevel Hierarchies 66415.7.3 Can Operators Be Made to Behave

Polymorphically? 66715.7.4 Polymorphic Types 667

15.8 Static versus Dynamic Binding for Functions in C++ 66815.9 Restrictions on Overriding Functions in C++ 67215.10 Virtual Destructors in C++ 676

CONTENTS xxiii

15.11 Constructor Order Dependencies in C++ 67815.12 Abstract Classes in C++ 68115.13 Protected and Private Derived Classes in C++ 68615.14 Extending Classes in Java 69115.15 Restrictions on Overriding Methods in Java 69515.16 Constructor Order Dependencies in Java 69815.17 Abstract Classes in Java 69915.18 Interfaces in Java 702

15.18.1 Implementing Multiple Interfaces in Java 70715.18.2 Extending Interfaces in Java 70815.18.3 Constants in Interfaces 711

15.19 A C++ Study of a Small Class Hierarchy withModerately Complex Behavior 712

15.20 A Java Study of a Small Class Hierarchy exhibitingModerately Complex Behavior 727

15.21 Credits and Suggestions for Further Reading 73615.22 Homework 737

16 Multiple Inheritance in C++ 74316.1 Some Examples for MI 74416.2 Issues that Arise with Repeated Inheritance 75116.3 Virtual Bases for Multiple Inheritance 75316.4 Virtual Bases and Copy Constructors 75916.5 Virtual Bases and Assignment Operators 76216.6 Avoiding Name Conflicts for Member Functions 76916.7 Dealing with Name Conflicts for Data Members 77116.8 Implementation of an Example in Repeated

Inheritance 77316.9 Using Mixin Classes 78216.10 Using Role-Playing Classes 79016.11 Run-Time Type Identification in C++ 80216.12 Credits and Suggestions for Further Reading 80416.13 Homework 804

17 OO for Graphical User Interfaces, A Tour of Three Toolkits81117.1 A Brief History of GUI Toolkits 81217.2 AWT/Swing Components 81517.3 Qt Widgets 81717.4 GNOME/GTK+ Widgets 817

xxiv CONTENTS

17.5 Minimalist GUI Programs in AWT/Swing 81817.6 Minimalist GUI Programs in Qt 82317.7 Minimalist Programs in GNOME/GTK+ 82617.8 Layout Management in GUI Programs 83017.9 Layout Management in AWT/Swing 831

17.9.1 Border Layout 83217.9.2 Flow Layout 83417.9.3 Box Layout 83717.9.4 Grid Layout 84117.9.5 Card Layout 84317.9.6 Grid-Bag Layout 847

17.10 Layout Management in Qt 85217.10.1 Box Layout 85317.10.2 Grid Layout 856

17.11 Layout Management in GNOME/GTK+ 85917.11.1 Box Layout 85917.11.2 Table Layout 861

17.12 Event Processing in GUI Programs 86417.13 Event Processing in AWT/Swing 867

17.13.1 An Example in Inter-Component Communicationin AWT/Swing 875

17.14 Event Processing in Qt 88017.14.1 A Qt Example that requires Meta Object

Compilation 88317.14.2 Summary of Facts about Signals and Slots 892

17.15 Event Processing in GNOME/GTK+ 89317.15.1 Communicating Events to Other Widgets in

GNOME/GTK+ 89417.15.2 Summary of Facts about Callbacks in

GNOME/Gtk+ 90117.16 Windows with Menus in AWT/Swing 90317.17 Windows with Menus in Qt 90817.18 Windows with Menus in GNOME/GTK+ 91617.19 Drawing Shapes, Text, and Images in AWT/Swing 92517.20 Drawing Shapes, Text, and Images in Qt 94017.21 Drawing Shapes, Text, and Images in Gnome/GTK+ 94817.22 Java Applets 958

17.22.1 Life Cycle of an Applet 95917.22.2 The Applet Tag 960

CONTENTS xxv

17.22.3 An Applet Example 96217.22.4 Dual-Purpose Programming for Applets 97017.22.5 The AppletContext Interface 97317.22.6 Security Issues Related to Applets 978

17.23 Credits and Suggestions for Further Reading 98017.24 Homework 980

18 Multithreaded Object-Oriented Programming 98518.1 Creating and Executing Simple Threads in Java 98618.2 The Runnable Interface in Java 99018.3 Thread States 99218.4 Thread Interference in Java 99318.5 Thread Synchronization in Java 100118.6 Java’s � ����� – � ��� � ��� Mechanism for Dealing with

Deadlock 100518.7 Data I/O Between Threads in Java 101018.8 Java Threads for Applets 101218.9 The Event Dispatch Thread in AWT/Swing 101518.10 Multithreaded Programming in C/C++ 1024

18.10.1 Demonstrating Thread Interference withPOSIX Threads 1030

18.10.2 MUTEX for Dealing with POSIX ThreadInterference 1032

18.10.3 POSIX Threads: Condition Variables andthe � ��� � – #�������� � Mechanism for Dealing withDeadlock 1035

18.11 Object-Oriented Multithreading in C++ 104018.12 Credits and Suggestions for Further Reading 104618.13 Homework 1047

19 Network Programming 104919.1 Establishing Socket Connections with Existing Servers

in Java 105019.2 Server Sockets in Java 105319.3 Establishing Socket Connections with Existing Servers

in C++ 105919.4 Server Sockets in C++ (Qt) 106619.5 Suggestions for Further Reading 107519.6 Homework 1075

xxvi CONTENTS

20 Database Programming 113720.1 Relational Databases 113820.2 The MySQL Database Manager 114020.3 SQL 114120.4 JDBC Programming: Invoking SQL through Java 115220.5 Mysql++ Programming: Invoking SQL through C++ 115720.6 Suggestions for Further Reading 116320.7 Homework 1163

Index 1165

Index

*as iteration marker (UML), 599for iterator dereferencing (C++), 154for multiple triggers (UML), 613for pointer dereferencing, 519for representing multiplicity (UML), 593to show all columns (SQL), 1062�

address operator (C++), 297for iterator initialization (C++), 157

��� , member access operator (C++), 519��� * (C++), 463//, 9, 14:: (C++), 61, 6191..* (UML), 593� �

(C++), 114, 150, 510.* (C++), 463�

, for protected visibility (UML), 595� , for private visibility (UML), 595�

, for public visibility (UML), 595�, 152, 513

��� , 154���, 154���(C++), 9, 628

��� (C++), 16�

(C++), 78, 115, 152, 171, 513(Java), 79, 135�(C++), 79, 171, 176, 178, 182�

(C++), 152

� (C++), 152, 513� (C++), 152��� ��� (UML), 596

A

abort() (C++), 23, 393absolute positioning for layout, 810abstract

a keyword, 677class, 73, 75, 617, 660, 677, 761function, 662method, 662

AbstractCollection (Java), 75–76AbstractList (Java), 75–76AbstractShape.cc, 661AbstractShapeIncremental.cc, 662AbstractShapeIncremental.java, 678Abstract Window Toolkit (AWT/Swing), 793accelerator, keyboard, 889, 895accept() (Java), 1032, 1045Access, 1059access control, 3, 30, 71

package, 71private, 34, 38, 71protected, 71public, 34, 38, 71

acl.read property (Java), 957acl.write property (Java), 957acquiring lock

1165

1166 INDEX

on a class, 979on an object, 979

ActionEvent (AWT/Swing), 882ActionListener (AWT/Swing), 845, 847, 850,

882–883, 941, 954actionPerformed() (AWT/Swing), 850, 882, 884,

941action (UML), 606activate() (Qt), 833, 836activation (UML), 602

icon, 598activity

diagram (UML), 588, 611state (UML), 606

actor (UML), 588adapter

class (AWT/Swing), 680, 845container (C++), 151, 173, 175

ADD (SQL), 1069add() (Java), 182, 186, 190addActionListener() (AWT/Swing), 799, 848, 850addAll() (Java), 186AddArray1.c, 6AddArray2.c, 7AddArray.cc, 7AddArray.java, 10addComponentListener() (AWT/Swing), 852addElement() (Java), 194, 196addFocusListener() (AWT/Swing), 852addImage() (AWT/Swing), 915addItemListener() (AWT/Swing), 822addKeyListener() (AWT/Swing), 852addMouseListener() (AWT/Swing), 852addMouseMotionListener() (AWT/Swing), 852addMultiCellWidget() (Qt), 836addWidget() (Qt), 833, 835–836addWindowListener() (AWT/Swing), 799, 848,

850adjacent find() (C++), 567affine transformation, 919, 928aggregation (UML), 591, 594algorithm, a C++ header file, 8ALIGN, 937–938alignment (Qt), 833ALT, 938ALTER (SQL), 1067, 1069ALTER TABLE (SQL), 1062American National Standards Institute, 8amortized constant-time complexity, 151anchor

(C), 927(Java), 827

animated applets, 964animation, 990Animator.java, 991anonymous class (Java), 571, 850

ANSI, 8API, Application Programming Interface, 791app (C++), 238–239append()

(C++), 119(Java), 133, 138

append file mode(C++), 239(Java), 267

APPLET tag (HTML), 937–938, 947Applet (Java), 936applet (Java)

animated, 964context, 951security, 936

appletviewer tool (Java), 956, 937, 947application, 13

programming interface, 791approximate numerics (SQL), 1060argc, 20, 804argument-dependent name lookup (C++), 70argument object, 503argv, 20, 804ArithmeticException (Java), 409arithmetic types (C++), 223arity of an operator, 498, 504array

(C), 6(Java), 14declaration

(C++), 306(Java), 311

initialization(C++), 301, 308(Java), 311

of pointers (C++), 300parameter (C), 7

ArrayBasic.java, 313array-like random access, 150ArrayList (Java), 75, 185–186, 194, 569, 205,

1034, 569Arrays (Java), 55, 315ArraysFill.java, 316ArraySizeOf.cc, 128ArraysShuffle.java, 317ASCII, 109, 212, 214–215, 218, 247asList() (Java), 201, 315assert() (C++), 121assign() (C++), 129assignment operator

(C++), 452for derived class, 626

(Java), 455AssignTest.java, 456association (UML), 591, 769

bidirectional, 593

INDEX 1167

binary, 593multiplicity, 592reflexive, 593rolename, 592

associative container (C++), 151, 565asynchronous

image loading, 915method invocation, 601

at() (C++), 114ate (C++), 239, 248atomic components

(AWT/Swing), 794(GNOME/GTK+), 796(Qt), 795

attribute(s)(UML), 590of POSIX threads, 1003representation (UML), 595visibility (UML), 595

automatic type conversion(C++), 224(Java), 228for assignment, 223for conversion of operands to common type, 223for conversion of returned value, 223for initialization, 223for matching argument with parameter, 223for primitive types, 223

auto ptr (C++), 529AWT (Java), 794, 790–792

thread, 993

B

back() (C++), 157, 174–175bad() (C++), 243base

class, 31(C++), 42(Java), 47, 669private (C++), 618protected (C++), 618public (C++), 618slice, 622

indirect, 732virtual (C++), 731

baseline for drawing a string, 908basic ifstream<char> (C++), 237basic ifstream<wchar t> (C++), 237basic istream<char> (C++), 237basic istream<wchar t> (C++), 237basic ostream (C++), 8basic string (C++), 113begin() (C++), 154, 565behavior of a class, 29BidirectionalIterator (C++), 566–568big-endian, 134, 221, 250, 259

binary, 239I/O

(C++), 247(Java), 259

mode, 246mode for I/O (C), 20numeric promotion, 215, 227, 232operator, 499stream (C++), 246association (UML), 593

BinaryFileIO.cc, 247BinaryFileIO2.cc, 248BinaryFileIO3.cc, 251binary search (C++), 182binarySearch() (Java), 316BIT (SQL), 1061BIT (n) (SQL), 1061bitset

a C++ container class, 150, 152a C++ header file, 8

bit strings (SQL), 1060BIT VARYING (n) (SQL), 1061block, 304

nested (C++), 304scope

(C++), 66, 303–304(Java), 305

blocked state, 970blocking

inheritance (Java), 49, 680I/O, 16

BlockInheritance.cc, 52BlockInheritance.java, 49BlockInheritance2.java, 50bool (C++), 213boolean (Java), 19, 211, 213bootclasspath (Java), 571Border (AWT/Swing), 810, 813BorderFactory (AWT/Swing), 810, 813, 817, 822BorderLayout (AWT/Swing), 799–800, 809–810,

817BorderLayoutTest.java, 810born state, 967, 970BOTH (AWT/Swing), 826BOTTOM (AWT/Swing), 813, 822bottom attach (GNOME/GTK+), 840BoxLayout (AWT/Swing), 809, 815BoxLayoutTest.java, 817bridge driver, 1055brighter() (AWT/Swing), 905browser, 936–938

Java enabled, 939JVM, 937, 940, 942–943

BufferedOutputStream (Java), 264BufferedReader (Java), 1029, 205buffered TCP socket, 1038

1168 INDEX

buffer flushing, 258buffering of a stream, 258byte (Java), 221bytecode (Java), 11byteWritten() (Qt), 1038

C

callback, 807, 844, 871, 873, 879, 932capacity, 197

(C++), 124(Java), 132

capacity() (Java), 132CardLayout (AWT/Swing), 809, 821CardLayoutTest.java, 822CASE INSENSITIVE ORDER, 137case label, 305cast, 117, 223, 232, 234casting away const (C++), 781catch clause

(C++), 389(Java), 400

C++ compilation, 5with CC, 10with g++, 9

CDE, 791CENTER (AWT/Swing), 810, 813, 819, 822, 827cerr (C++), 21, 23, 239changeUpdate() (AWT/Swing), 854char, 213–214, 218, 796

signed, 796unsigned, 796

char* (C), 108CHAR (n) (SQL), 1060–1061CHAR (SQL), 1061CHARACTER

(SQL), 1061VARYING(n) (SQL), 1061

CHARACTER(n) (SQL), 1061Character (Java), 194character, 211

constant, 215escape, 215literal, 215strings (SQL), 1060

charAt() (Java), 134CharEscapes.cc, 216CharEscapes.java, 219ChatServer

(C++), 1045(Java), 1031

ChatServer.cc, 1048ChatServer.h (Qt), 1047ChatServer.java, 1035C header files used in C++, 386C++ header files, 8

algorithm, 8

bitset, 8complex, 8deque, 8exception, 8fstream, 8functional, 8iomanip, 8ios, 8iosfwd, 8iostream, 8istream, 8iterator, 8limits, 8list, 8locale, 8map, 8memory, 8new, 8numeric, 8ostream, 8queue, 8set, 8sstream, 8stack, 8stdexcept, 8streambuf, 8string, 8typeinfo, 8utility, 8valarray, 8vector, 8

checked exception (Java), 25, 399, 408cin (C++), 16–17, 239class, 2, 29

abstract, 617anonymous (Java), 850base, 31

(C++, 42(Java), 47

behavior of, 29concrete, 76definition

(C++), 32(Java), 37

derivationprivate (C++), 664protected (C++), 664public (C++), 617(Java), 669

derived, 31(C++), 42, 617(Java), 46, 669

diagram (UML), 588, 590conceptual, 592implementation, 592specification, 592

INDEX 1169

extended(C++), 42, 617(Java), 46, 669

field of, 30generic, 547hierarchy, 30

IsA, 31role-based, 768

inner (Java), 91instance of, 29mixin, 721, 760–761nested, 89

static (Java), 89parameterized

(C++), 555(Java), 568

relationshipHasA, 591IsA, 591

responsibility (UML), 592role playing, 721, 768scope operator (C++), 36sub-, 31super-, 31template, 547

(C++), 83, 555(Java), 574

variable, 422ClassCastException (Java), 409, 568–569, 706CLASSPATH environment variable, 12classpath (Java), 11, 57, 570

option, 5clear() (Java), 182clicked, a signal, 807clicked()

(GNOME/GTK+), 871(Qt), 859

client, 1027–1028ClientHandler

(C++), 1046(Java), 1031–1032

client–server networking model, 1027ClientSocket.cc, 1041ClientSocket.h (Qt), 1040clone() (Java), 456–457CloneArray1.java, 460Cloneable (Java), 75–76, 457ClonableX.java, 458CloneBasic.java, 458CloneClassTypeArr.java, 462CloneNotSupportedException (Java), 457cloning (Java), 457close() (C++), 23Closing (Qt), 1039closing

a stream

(C++), 23, 247, 251(Java), 24, 261, 263, 266

CODE, 938CODEBASE, 938collaboration diagram (UML), 597, 603Collator (Java), 145Collection (Java), 75, 182, 184

GJ, 571view, 193

CollectionMaxGeneric.java, 577Collections (Java), 197

Framework, 80Color (AWT/Swing), 810, 813, 905command-line

arguments(C++), 19, 801(Java), 24

compilation, 5(C++), 9(Java), 11(Qt), 802

comma separated values, 1073comment delimiters, 9commenting code, 9, 14Common Desktop Environment, 791communication (UML), 590communication association (UML), 590Comparable (Java), 81, 136, 579Comparator (Java), 137, 145, 183, 186, 198,

576–577, 579compare()

(C++), 115(Java), 137

compareTo() (Java), 81, 135–136, 183, 186comparing objects, 77compiling

(C++), 5, 9(GNOME/GTK+), 805(Java), 11(Qt), 802, 862

complex, a C++ header file, 8–9Component (AWT/Swing), 797, 852, 903–904,

916component

heavyweight (AWT/Swing), 793lightweight (AWT/Swing), 793peered (AWT/Swing), 793peerless (AWT/Swing), 793

ComponentEvent (AWT/Swing), 852composite key (SQL), 1062composition (UML), 591, 594compound stream (Java), 264concat() (Java), 129conceptual perspective (UML), 592concrete class, 76concurrent

1170 INDEX

computing, 963processing, 602statechart diagram (UML), 608

ConcurrentModificationException, 189, 205condition

function (C++), 243synchronization bar (UML), 611variable (POSIX), 1010, 1013

connectdeclaration (Qt), 844signal with slot (Qt), 859

connect() (Mysql++), 1076connected() (Qt), 1038Connecting (Qt), 1039connectionClosed() (Qt), 1038Connection

(Java), 1059, 1070(Mysql++), 1075

connectToHost() (Qt), 1038const (C++), 51, 76, 292, 317, 595

char*, 108, 116function parameter, 345, 363member function, 435return type from a function, 364

constant-time complexity, 150const cast (C++), 234, 781const iterator (C++), 169, 568ConstRefReturn.cc, 359const reverse iterator (C++), 568constructor, 33, 38

derived class(C++), 621(Java), 669

no-arg(C++), 43, 286, 288–289, 307, 621, 623(Java), 47, 296–297, 312–313, 669

one-arg, for implicit type conversion (C++), 535order dependencies

(C++), 657(Java), 676

overloading(C++), 366(Java), 371

ConstructorLeak.cc, 521ConstructorLeakPlugged.cc, 528ConstructorOrder.cc, 657ConstructorOrderFoo.cc, 659ConstructorOrderFoo.java, 676Container (AWT/Swing), 797, 904container

classes(C++), 148(Java), 182

GUIintermediate (AWT/Swing), 794intermediate (GNOME/GTK+), 796

intermediate (Qt), 795top-level (AWT/Swing), 793top-level (GNOME/GTK+), 796top-level (Qt), 795

containment hierarchy, 793, 801–802content pane (AWT/Swing), 797–798conversion specifier (C), 15coordinate transformation, 910, 919copy

assignment operator (C++), 166, 450, 452, 508prototype, 452

constructor (C++), 113, 450, 452, 507example definition, 452for derived class, 624for multiple bases, 625prototype, 452

on return from function (C++), 359copy() (C++), 206, 566CopyAssignX.cc, 454copyInto() (Java), 195CopyOnReturn.cc, 358CountDestructorInvoc1.cc, 377CountDestructorInvoc2.cc, 378CountDestructorInvoc3.cc, 378CountDestructorInvoc4.cc, 379CountDestructorInvoc5.cc, 380CountDestructorInvoc6.cc, 381cout (C++), 8, 23, 239cp, for classpath (Java), 570CrazyWindow.c, 874CrazyWindow.cc, 864CrazyWindow.h (Qt), 864CrazyWindow.java, 855createEmptyBorder() (AWT/Swing), 817createHorizontalGlue() (AWT/Swing), 816–817createHorizontalTextPosition() (AWT/Swing), 822createLineBorder() (AWT/Swing), 810, 813, 819,

822createRigidArea() (AWT/Swing), 815, 817createStatement() (Java), 1070CREATE TABLE (SQL), 1060, 1063, 1073createVerticalGlue() (AWT/Swing), 816.cshrc, 570C++ Standard Library, 8c str() (C++), 114C-style string, 108csv, 1073cur (C++), 241currentTimeMillis() (Java), 55–56

D

daemon thread, 1003, 1025darker() (AWT/Swing), 905DashDotLine (Qt), 921DashLine (Qt), 921data

INDEX 1171

abstractions, uncoupling of, 726encapsulation, 29hiding, 30member, 29, 32, 37

database, 1055desktop-based, 1057driver, 1055, 1058management system, 1058programming, 2relational, 1056–1057server-based, 1057URL, 1059

DataInputStream (Java), 271, 273, 990DataOutputStream (Java), 264, 269–270, 990Date.cc, 425Date.java, 432DATE (SQL), 1061datetimes (SQL), 1060DB2, 1059dBase, 1059DBFriends1.java, 1071DBFriends2.java, 1074deadlock, 1013, 983

irresolvable, 987dead state, 970dec, a stream manipulator (C++), 253DECIMAL (SQL), 1061decimal integer literal, 221decision activity (UML), 612declaring

an identifier, 283multiple names, 302pointer types (C++), 297

decompiling (Java), 975decrement operator, overloading of (C++), 529default

arguments for C++ functions, 373,initialization

array, 307,(C++), 286(Java), 293template parameter (C++), 564

layout manager, 809DefaultInit.cc, 287DefaultInit.java, 294DefaultInit2.cc, 288DefaultInit2.java, 295DefaultInit3.cc, 289DefaultInit3.java, 296DefaultInit4.cc, 290DefaultInitClassArray.cc, 309DefaultInitClassArray2.cc, 310DefaultInitPrimArray.cc, 308�

define (C++), 319defining an identifier, 283delayedClosedFinished() (Qt), 1038

DELETE (SQL), 1068delete (C++), 34, 46, 299, 334, 443, 520, 633delete() (Java), 141delete[] (C++), 46, 334, 444, 520deleteCharAt() (Java), 135delimiter character, 192, 211depth index, 798deque

a C++ container class, 149–150, 168, 174, 567a C++ header file, 8

DequeFront.cc, 168dereferencing

an iterator (C++), 154a pointer (C++), 297operator (C++), 519

derivationclass (C++)

private, 664protected, 664, 728public, 617

class (Java), 669DerivedAssignOp.cc, 626derived class, 31

(C++), 42private, 664protected, 664public, 621constructor, 621copy constructor, 624destructor, 632

(Java), 47,constructor, 669

DerivedConstructor.cc, 621DerivedConstWithBaseNoArg.cc, 622DerivedCopyConstruct.cc, 624DerivedDestructCase1.cc, 633DerivedDestructCase2.cc, 634DerivedDestructCase3.cc, 636DerivedNameConflict.cc, 620DerivedOverloadOp.cc, 629DESCRIBE (SQL), 1064, 1069deselecting a layout manager, 830design patterns, 3, 789desktop-based database, 1057Dest.cc, 54destroy() (AWT/Swing), 937Destruct.cc, 441Destruct2.cc, 442destructor (C++), 34, 54, 166, 507, 617

default definition, 633explicit invocation, 446for derived class, 632virtual, 727, 781

DestructorNecessary.cc, 444DestructWhenNot.cc, 445detachstate (POSIX), 1003

1172 INDEX

diamond class hierarchy (C++), 785DiffScope.cc, 370Dimension (AWT/Swing), 813, 815–817Dining Philosophers Problem, 1025directive, using (C++), 9, 64disjunctive activity (UML), 612dispatcher thread (Java), 965DNS lookup, 1038Document (AWT/Swing), 854DocumentEvent (AWT/Swing), 847, 854DocumentListener (AWT/Swing), 847, 854DotLine (Qt), 921double, 213, 222

largest positive value, 222precision, 222smallest positive value, 222

DOUBLE PRECISION (SQL), 1061downcasting (C++), 780dramatic result set (Mysql++), 1077drawImage() (AWT/Swing), 916drawRect()

(AWT/Swing), 905(Qt), 920

drawString() (AWT/Swing), 908driver manager, 1059DriverManager (Java), 1059, 1070DROP TABLE (SQL), 1062, 1067DuplicateBase.cc, 743dynamically expandable array, 75dynamic binding (C++), 647dynamic cast (C++), 234, 700, 780

with object reference, 781

E

EAST (AWT/Swing), 810, 827ECHO network service, 1028elementAt() (Java), 195EMBED tag, 947emission

of event, 844of signal, 844

Employee.h, 694empty

space (AWT/Swing)glue, 815invisible component, 815rigid area, 815

string(C++), 113(Java), 132

empty() (C++), 174–175encapsulation, 3, 29–30

in simulated OO in C, 95EnclosedClassAccess.cc, 87EnclosingClassAccess.java, 90end() (C++), 154, 565

endl, a stream manipulator (C++), 255end-of-file, 16ends, a stream manipulator (C++), 255endsWith() (Java), 141entrySet() (Java), 194enum (C++), 88, 214, 319Enum.cc, 320enumerator (C++), 320EnumWithLabelArray.cc, 323EOF (C), 21eof() (C++), 23, 243equality operator (C++), 513EqualityTest.java, 80equals() (Java), 79, 135erase() (C++), 123, 159, 180, 208erase substring

(C++), 123(Java), 141

ErrConnectionRefused (Qt), 1040ErrHostNotFound (Qt), 1040error(), 1038error code, returned by pthread function (POSIX),

1003error indicators for I/O stream (C), 21Error (Java), 408ErrSocketRead (Qt), 1040escape

hexadecimal, 215octal, 215sequence, 215

event, 932definition, 842emission, 844high-level (AWT/Swing), 845high-level (Qt), 858in UML, 606low-level (AWT/Swing), 845low-level (Qt), 858processing, 842

by macros and messages, 844by virtual function (Qt), 844loop, 844loop (AWT/Swing), 845, 857, 993loop (GNOME/GTK+), 871loop (Qt), 802, 858

queue, 842source, 845

eventDestroy() (GNOME/GTK+), 807, 873Event Dispatch Thread (AWT/Swing), 857, 942,

964–965, 993, 995, 999Event[Guard]/Action (UML), 606EventThreadDemo.java, 993EventThreadDemo2.java, 995“exactly one superclass” rule (Java), 680exact numerics (SQL), 1060Excel, 1059

INDEX 1173

Exception (Java), 399exception

a C++ header file, 8–9checked (Java), 399, 408handler, 389handling, differences between C++ and Java,

399specification

(C++), 393(Java), 403, 674

unchecked (Java), 399, 408ExceptionUsage1.cc, 392ExceptionUsage1.java, 402ExceptionUsage2.cc, 392ExceptionUsage2.java, 403ExceptionUsage3.cc, 393ExceptionUsage3.java, 403ExceptionUsage4.cc, 394ExceptionUsage4.java, 404ExceptionUsage5.cc, 395ExceptionUsage5.java, 405ExceptionUsage6.cc, 396ExceptionUsage6.java, 406ExceptionUsage7.cc, 397ExceptionUsage7.java, 407ExceptionUsage8.cc, 397ExceptionUsage9.cc, 398exec() (Qt), 802, 831–832, 834, 836executable class, 13execute() (Mysql++), 1076executeQuery() (Java), 1070exit()

(C), 19–20(C++), 23

EXIT FAILURE (C), 19–20expand (GNOME/GTK+), 838expandable empty space (AWT/Swing), 816ExplicitCast1.cc, 232ExplicitCast1.java, 234ExplicitCast2.cc, 233ExplicitCast2.java, 235explicit

constructor invocation (Java), 422keyword for suppressing implicit type

conversion (C++), 527, 535–536type conversion, 223

(C++), 232, 234, 618(Java), 234

extend (UML), 590extended

class (C++), 42class (Java), 47,

extendinga class

C++, 664,,Java, 669

an interface (Java), 686extends (Java), 47, 669extension point (UML), 590extern, 69

“C” directive (C++), 386, 488extracting substring

(C++), 122(Java), 141

extraction operator (C++), 16

F

fail() (C++), 243fail-fast (Java), 189, 204fast mutex (POSIX), 1011fclose() (C), 19ferror() (C), 19field, 30, 32, 37FILE* (C), 20FileCopy.c, 19FileCopy.cc, 21FileCopy.java, 23FileDialog (AWT/Swing), 883FileInputStream (Java), 24FileOutputStream (Java), 262, 270file

pointer(C), 20(C++), 239(Java), 266

scope (C++), 303–304FileReader (Java), 27, 205FileWriter (Java), 263, 266, 269fill

(AWT/Swing), 826(GNOME/GTK+), 838(Qt), 920methods for Java arrays, 315methods for C++ containers, 182

fill()(C++), 253(Java), 316

fill color, 927Filler (AWT/Swing), 816fillOval() (AWT/Swing), 908finalization (Java), 55, 446finalize() (Java), 55, 446–447finalizer thread (Java), 965final (Java), 317, 365, 595, 690

for blocking inheritance, 49for read-only variable, 51, 76function parameter, 345

finally (Java), 401, 405find() (C++), 120, 159, 182, 565–566find first not of() (C++), 120find first of() (C++), 120find last not of() (C++), 120

1174 INDEX

find last of() (C++), 120FINGER network service, 1028first (C++), 179first-in first-out scheduling, 1004FirstWindow.c, 805FirstWindow.cc, 801FirstWindow.java, 796FirstWindowWithButton.c, 806FirstWindowWithButton.cc, 803FirstWindowWithButton.java, 799fixed, a stream manipulator (C++), 255flat file, 1073FLOAT (SQL), 1061float, 213, 222

largest positive value, 222precision, 222smallest positive value, 222

floatinga component, 809pallet, 798toolbar, 798

floating-point, 211arithmetic

rounding modes, 227exponent, 222fraction, 222literal, 223mantissa, 222overflow, 222precision, 222sign, 222types, 222underflow, 222

FlowLayout (AWT/Swing), 794, 800, 809, 812FlowLayoutTest.java, 813flush, a stream manipulator (C++), 255flushing an output stream buffer (C++), 255FOC, focus of control (UML), 602FocusEvent (AWT/Swing), 852focus of control (UML), 602Font (AWT/Swing), 908font, default, 908FontFamilies.java, 908fopen() (C), 19–20FOREIGN KEY (SQL), 1061format state of a stream (C++), 252ForwardIterator (C++), 566–567fprintf() (C), 19Frame (AWT/Swing), 794FRAMESET tag, 952free-form sketching, 919friend (C++), 53, 72, 420, 503, 628Friend.cc, 72front() (C++), 157, 175frozen (UML), 595fstream

a C++ header file, 8, 22, 238a read and write stream (C++), 239

FTP network service, 1028function

calling modesdifferences between C++ and Java, 357

call operator (C++), 538inlining (C++), 345, 360object (C++), 79, 176, 207, 538overloading, 345

(C++), 366, 368overriding, 44

(C++), 46, 49(Java), 47

parameterized(C++), 557(Java), 577

prototype (C++), 22, 346prototype scope (C++), 303, 305scope (C++), 303, 305signature, 369, 651stack, 388template

(C++), 556–557(Java), 577

virtual (C++), 44vs. method, 345

functional, a C++ header file, 8, 176functor (C++), 538, 693fundamental types, 213

G

g++, 9garbage collection, 964

C++, 334Java, 55, 335, 446

gboolean (GNOME/GTK+), 880gc() (Java), 55gchar (GNOME/GTK+), 796GC.java, 447gcount() (C++), 245, 247GC Resurrect.java, 449GDK 2BUTTON PRESS, 932GDK 3BUTTON PRESS, 932GDK BUTTON PRESS, 932GDK BUTTON RELEASE, 932GDK, 795GDK DRAG ENTER, 932GDK DRAG LEAVE, 932GDK DRAG MOTION, 932GdkEvent*, 932GdkEventButton*, 932gdk imlib create image from xpm data(), 927GdkImlibImage, 927GDK MOTION NOTIFY, 932generalization, 591, 769

INDEX 1175

UML, 590generic

algorithms(C++), 181(Java), 197

class, 547, 568program, 548

Generic Java, 569getAllFonts() (AWT/Swing), 908getAppletContext() (Java), 956getAppletInfo() (AWT/Swing), 946getAvailableFontFamilyNames() (AWT/Swing),

908get() (C++), 15, 17, 21–22, 243, 247getc() (C), 19, 21getchar() (C), 14–15getColumnCount() (Java), 1071getConnection() (Java), 1059getContentPane() (AWT/Swing), 798getDefaultToolkit() (AWT/Swing), 915getFile() (AWT/Swing), 883getFilePointer() (Java), 266getID() (AWT/Swing), 852, 914getImage()

(AWT/Swing), 915(Java), 991

getInputStream() (Java), 1029getInsets() (AWT/Swing), 904getline() (C++), 245getLocalGraphicsEnvironment() (AWT/Swing),

908getMetaData() (Java), 1071getOutputStream() (Java), 1029getParameter() (Java), 956getParameterInfo() (AWT/Swing), 946getPoint() (AWT/Swing), 915get position (C++), 240getProperty() (Java), 957GET request, 1028–1029GetThirdType.cc, 244getX() (AWT/Swing), 915getY() (AWT/Swing), 915GHBoxTest.c, 838.gif, 915GIF, 915GIMP (GNOME/GTK+), 795GIMP Drawing Kit (GNOME/GTK+), 795GIMP Took Kit (GNOME/GTK+), 795gint16 (GNOME/GTK+), 796gint8 (GNOME/GTK+), 796gint (GNOME/GTK+), 796, 880gjc (Java), 569gjc.Main (Java), 570gjcr (Java), 569GJ (Java), 569glass pane (AWT/Swing), 797–799

glib library (GNOME/GTK+), 795global

namespace (C++), 62, 386overload definition (C++), 498scope (C++), 62

glue(AWT/Swing), 816code (Qt), 862

g malloc() (GNOME/GTK+), 796GNOME APP, 896gnome app create menus(), 896gnome app new(), 804GNOME APP PIXMAP FILENAME, 896GNOME APP PIXMAP NONE, 896GNOME APP UI HELP, 895, 897GNOME APP UI ITEM, 895GNOME APP UI SUBTREE, 895, 897GNOME, 871GnomeCanvas, 926, 932GnomeCanvasGroup, 874, 926GnomeCanvasItem, 874gnome canvas item new(), 874, 926gnome canvas line get type(), 933GnomeCanvasPoints, 928GnomeCanvasPoints*, 933gnome canvas root(), 874gnome canvas set scroll region(), 927gnome-config, 805GNOME, desktop environment, 790, 793, 795GNOME/GTK+, 2, 795gnome init(), 804GnomeUIInfo, 894, 897GNOMEUIINFO END, 897GNOMEUIINFO HELP, 897GNOMEUIINFO SEPERATOR, 897GNOMEUIINFO SUBTREE, 897GNU

C++ compiler, g++, 9General Public License, 1058Image Manipulation Program (C), 795Object Modeling Environment (C), 795

golden proportion, 789good() (C++), 243GPL, 1058g print() (GNOME/GTK+), 796grant table, 1058graphical user interface, 2Graphics2D (AWT/Swing), 903, 910Graphics (AWT/Swing), 794, 854, 903–905, 907graphics context, 903GraphicsDevice (AWT/Swing), 909GraphicsEnvironment (AWT/Swing), 908green threads, 964GridBagConstraints (AWT/Swing), 825, 827GridBagLayout (AWT/Swing), 809, 825GridBagLayoutTest.java, 828

1176 INDEX

gridheight (AWT/Swing), 826GridLayout (AWT/Swing), 809, 819, 849GridLayoutTest.java, 819gridwidth (AWT/Swing), 826gridx (AWT/Swing), 826gridy (AWT/Swing), 826GTK+, 790, 793GtkAttachOptions, 840GtkBin, 880gtk box pack end(), 839gtk box pack start(), 838–839GtkButton, 879gtk button new with label(), 807, 840GTK, 795GTK+, 791, 795, 871GTK CONTAINER, 805GtkContainer, 880gtk container set border width(), 805gtk editable get chars(), 874gtk editable get position(), 874GtkHBox, 837gtk hbox new(), 837gtk idle add(), 881gtk main(), 805, 871, 881gtk main() (GNOME/GTK+), 808gtk main quit(), 871, 881gtk main quit() (GNOME/GTK+), 805, 808GtkModifierType, 896GtkObject, 796, 880GTK POLICY NEVER, 874gtk scrolled window add with viewport(), 873gtk scrolled window new(), 873gtk scrolled window set policy(), 873–874gtk signal connect(), 871, 879, 932gtk signal emit(), 871gtk signal emit by name(), 871gtk signal query(), 880GtkSignalQuery, 880GtkTable, 837, 839gtk table attach defaults(), 840gtk text new(), 873gtk text set line wrap(), 873gtk type name(), 880GtkVBox, 837gtk vbox new(), 839GtkWidget, 796, 880gtk window new(), 804, 873GTK WINDOW TOPLEVEL, 804guard (UML), 606guchar (GNOME/GTK+), 796GUI, 2

history, 790

H

handler, exception, 389handshaking for reliable transmission, 1028

HasA relationship, 591hash

map(C++), 180(Java), 184, 191

table(C++), 151(Java), 184

hash map, a C++ container class, 180HashMap, a Java container class, 184, 191HashSet, a Java container class, 189HashTable, a Java container class, 184hasMoreTokens(), 205hasMoreTokens() (Java), 27hasNext() (Java), 186, 190hasPrevious() (Java), 186heap, 299, 632heavyweight component (AWT/Swing), 793HEIGHT, 938height-balanced binary tree, 183, 191HelloThreadWithJoin.cc, 1018hex, 216

a stream manipulator (C++), 253dump, 246

hexadecimaldigit, 216escape, 215integer

literal, 221notation, 221

HideScope.cc, 304hierarchical structures, 1hierarchy, 30

role-based, 768high-level event, 845, 858hints to a layout manager, 815homogeneous (GNOME/GTK+), 837, 840HORIZONTAL (AWT/Swing), 826hostFound() (Qt), 1038, 1041HostLookup (Qt), 1039.hotjava, 957HSPACE, 938HTML, 937, 939, 947, 953, 990HTMLConverter tool, 947HTTPD server, 1028–1029, 1040

I

IDE, 845identifier, 211–212

declaration, 283default initialization, 283definition, 283scope, 283

Idle (Qt), 1039idle function, 881ID number, 880

INDEX 1177

IEEE 754 Standard, 222, 227ifstream (C++), 21–22, 237–238ignore() (C++), 245IllegalArgumentException (Java), 409Image (AWT/Swing), 915, 940, 942ImageIcon (AWT/Swing), 810, 813, 819, 822, 940,

942–943ImageLoadAndDisplay.java, 917image loading

asynchronous, 915monitoring of, 915

ImageObserver (AWT/Swing), 916immutable, 129, 200implementation inheritance (C++), 665ImplementationInheritance.cc, 667implementation perspective (UML), 592implementing an interface (Java), 77implicit type conversion, 223

(C++), 224, 232, 533for class-types (C++), 534(Java), 228

import (Java), 24, 56–57, 605in (C++), 239include (UML), 590including C header files in C++, 386increment operator overloading (C++), 529indefinite number (UML), 593indexOf() (Java), 140IndexOutOfBoundsException (Java), 315indirect base, 732indirection (C++), 297�����

, 222inheritance, 3, 29, 31, 43

in simulated OO in C, 95loop (C++), 760multiple (C++), 75

inheritsched (POSIX), 1004init() (AWT/Swing), 903, 936–937, 941, 991initial capacity, 186, 190initialCapacity, 197initialization of

arrays(C++), 301, 307–308(Java), 311

base-class subobject(C++), 623(Java), 669

class typedefault (C++), 287default (Java), 296

const class member (C++), 292reference type (C++), 292, 330object reference

(Java), 333static class members (C++), 423static class members (Java), 433

static const class members (C++), 422static final (Java), 430variables

default (C++), 286default (Java), 293

initialization static (C++), 422inlining (C++), 36, 345, 360inner class (Java), 91InnerClass.java, 92InnerClassThisPrefix.java, 92input

operator (C++), 16stream manipulators (C++), 255stream object state (C++), 23

InputEvent (AWT/Swing), 845InputIterator (C++), 566InputStream (Java), 18, 1029, 259, 990INSERT (SQL), 1060, 1062insert()

(C++), 123, 153, 159(Java), 141

insert substring(C++), 123(Java), 141

insertElement() (Java), 196inserter iterator (C++), 567insertion

formatted (C++), 9operator (C++), 9

insertUpdate() (AWT/Swing), 854, 999Insets (AWT/Swing), 904insets (AWT/Swing), 827instance of a class, 29instantiating a class, 2, 33INT (SQL), 1060int, 213, 220IntComparator (Java), 577INTEGER (SQL), 1061integer, 211Integer (Java), 18, 939Integer.java, 579integer

literal, 221decimal, 221hexadecimal, 221octal, 221

types, 220IntegerGeneric.java, 581Integer.parseInt() (Java), 17integral types

(C++), 223(Java), 223

interaction diagram (UML), 588, 597Interactive Design Environment, 845interface (Java), 3, 74–75, 680

for packaging constants, 689

1178 INDEX

nested, 89parameterized, 573

interference, thread, 971Interleaved.cc, 470interleaved classes, 298, 466Interleaved.java, 481intermediate GUI containers, 794–796intern() (Java), 130InternalFrame (AWT/Swing), 794internal linkage (C++), 69, 304International Standards Organization, 8internet auction example, 588InterruptedException (Java), 984INTERVAL DAY (SQL), 1061intervals (SQL), 1060intValue() (Java), 191invariances, 789invisible component (AWT/Swing), 816invokeAndWait() (AWT/Swing), 1000invokeLater() (AWT/Swing), 1000invoking

a function on an object, 16object, 503

I/Obinary

(C), 20(C++), 246(Java), 261

character based(C++), 238(Java), 261

modes, 16asynchronous, 16blocking, 16nonblocking, 16

stream hierarchy(C++), 237(Java), 258

IOException (Java), 25iomanip, a C++ header file, 8, 256ios, a C++ header file, 8ios::app (C++), 238–239ios::ate (C++), 239, 248ios::binary (C++), 239ios::cur (C++), 241ios::fixed (C++), 255ios::in (C++), 239, 241ios::left (C++), 253ios::noshowpoint (C++), 254ios::noskipws (C++), 255ios::out (C++), 239, 241ios::scientific (C++), 254ios::showbase (C++), 254ios::showpoint (C++), 254ios::skipws (C++), 255ios::trunc (C++), 239

iosfwd, a C++ header file, 8iostream

a C++ header file, 8a C++ I/O stream class, 237

IP address, 1027–1028ipadx, padding variable (AWT/Swing), 827ipady, padding variable (AWT/Swing), 827irresolvable deadlock, 987IsA relationship, 31, 591, 682isEmpty() (Java), 183isEventDispatchThread() (AWT/Swing), 993ISO, 8, 421ISO-Latin-1, 133istream

a C++ header file, 8a C++ input stream class, 237

istringstream (C++), 257istrstream (C++), 257itemStateChanged() (AWT/Swing), 822Iterator (Java), 186, 190

GJ, 571iterator

a C++ header file, 8adapter (C++), 567(C++), 153, 171, 181, 565

BidirectionalIterator, 567class, 565forward incrementing, 566initialization, 565RandomAccessIterator, 567

(Java), 190dereferencing (C++), 154

iterator() (Java), 183

J

JApplet (AWT/Swing), 793–794, 797, 936, 1000JAR archive (Java), 12jar, the Java archive tool, 12Java

bytecode, 11Collections Framework, 205compilation, 5, 11Database Connectivity, 1055enabled browser, 939Foundation Classes, 794Plug-in for Swing applets, 947Runtime Environment, 947Virtual Machine, 11, 936, 964–965

java, the Java application launcher, 11java.awt.event package, 793java.awt.image package, 916java.awt package, 793javac, the compiler for Java, 11javadoc, Java documentation tool, 14java.io package, 24, 27, 267java.lang package, 56

INDEX 1179

java.net package, 1028, 1032javap, the Java class file disassembler, 975java.sql package, 1059, 1070java.util package, 185–186, 190, 193

GJ version, 569javax.swing.event package, 793javax.swing package, 793, 797JButton (AWT/Swing), 794, 827, 850JComboBox (AWT/Swing), 821

editable, 821uneditable, 821

JComponent (AWT/Swing), 798–799, 850, 903JDBC (Java), 1055, 1057, 1070

driver, 1055JDBC-ODBC bridge driver, 1059JDialog (AWT/Swing), 793–794, 797, 1000JFC (AWT/Swing), 794JFrame (AWT/Swing), 793–794, 797, 948, 1000JIT, just-in-time Java compilation, 11, 965JLabel (AWT/Swing), 810, 813, 819, 821–822,

940, 942JLayeredPane (AWT/Swing), 797JList (AWT/Swing), 816, 822jmp buf (C), 386join() (Java), 967join strings

(C), 110(C++), 118(Java), 138

JPanel (AWT/Swing), 794, 798, 816, 822, 853JPEG, 915.jpg, 915JRadioButton (AWT/Swing), 822JRE, 947JRootPane (AWT/Swing), 797JScrollBar (AWT/Swing), 794JScrollPane (AWT/Swing), 794, 816, 942JTabbedPane (AWT/Swing), 794, 821JTextArea (AWT/Swing), 854JTextField (AWT/Swing), 794just-in-time Java Compilation, 11JVM, 11, 936, 942

K

KEY (SQL), 1061keyboard

accelerator, 889, 895buffer, 16

KeyEvent (AWT/Swing), 845, 852keySet() (Java), 194key-sorted order, 184<key, value> pair, 149, 151, 178keyword, 211kind (UML), 596

in, 596inout, 596

out, 596Koenig.cc, 70Koenig lookup (C++), 70, 304

L

label, 305lastIndexOf() (Java), 140Latin-1, 213, 218layered pane (AWT/Swing), 797–798layout management, 808–809

(AWT/Swing), 809(GNOME/GTK+), 837(Qt), 830

LayoutManager (AWT/Swing), 830lazy instantiation, 416ldconfig, 802ld.so.conf, 802least-common-denominator approach, 794left, a stream manipulator (C++), 253left attach (GNOME/GTK+), 840Left.java, 954length (Java), 314length()

(C++), 124(Java), 132

less, a function object (C++), 176lexicographic ordering, 109, 136libqt-mt (Qt), 1019lifeline (UML), 597lightweight (AWT/Swing)

component, 793–794container, 797

limits, a C++ header file, 8linear time complexity, 150linkage, internal (C++), 69LinkedList

(C++), 548templatized, 555

(Java)a container class, 186GJ, 571

LinkedList.cc, 551LinkedList<double> (C++), 548LinkedListGeneric.cc, 557LinkedListGeneric.java, 574LinkedList<int> (C++), 548LinkedList<Integer> (Java), 549LinkedList.java, 571LinkedListSpecialized.cc, 561LinkedList<string> (C++), 548LinkedList<String> (Java), 549Linux, 1058, 802, 964–965LinuxThreads, 1013List

a Java container class, 75–76, 182, 186, 194, 569(AWT/Swing), 954

1180 INDEX

list(C++)

a container class, 149–150, 170, 567a header file, 8

(Java), 182, 185, 194ListGeneric.java, 569ListIterator (Java), 186ListMixedType.java, 569ListOps.cc, 171ListOps.java, 186List<String> (Java), 569literal

character, 215floating-point, 223integer, 221string, 108, 211, 216, 219

little-endian, 134, 250LOAD DATA INFILE (SQL), 1073load-factor, 190local

identifier, 304loopback address, 1035

Locale (Java), 145locale, a C++ header file, 8lock, 979, 984long, 213, 220

double (C++), 213, 222longjmp (C), 386look-and-feel, 791–794, 797loopback address, 1035, 1053low-level event, 845, 858

M

macro (C++), 319macros and messages, 844main widget (Qt), 801main WindowWithMenu.cc, 889makefile, 805–806, 808, 868, 878, 889, 902, 1043,

1052Makefile ChatServer, 1052Makefile ClientSocket, 1043Makefile GTK CrazyWindow, 878Makefile GTK FirstWindow, 806Makefile GTK RenderGraphics, 931Makefile GTK Sketch, 935Makefile GTK WindowWithMenu, 902Makefile Qt CrazyWindow, 868Makefile Qt WindowWithMenu, 889malloc(), 98, 110, 796, 1013Manager.cc, 701Manager.java, 707Mandrake, 802mangling, name (C++), 69, 386Map, a Java container class, 191map

(C++)

a container class, 149, 151, 178, 208, 567a header file, 8

(Java), 184, 191Map.Entry (Java), 194MapHist.cc, 179MapHist.java, 193mapping threads to native threads, 964mastering OO paradigm, 2Math (Java), 56max() (Java), 577maximum size recommendation, 815MediaTracker (AWT/Swing), 915, 942member

access operator (C++), 35, 39, 520function, 29

overload definition (C++), 501initialization syntax (C++), 36, 293, 658of a class, 32, 37

memorya C++ header file, 8–9, 529allocation

heap (C++), 299, 333heap (Java), 335stack (C++), 299

deallocation (C++), 334leak (C++), 46, 636segmentation fault, 299

Menu (AWT/Swing), 882menu, 881MenuBar (AWT/Swing), 882MenuItem (AWT/Swing), 882merge-sort, 137, 197, 315merging lists (C++), 171message (UML)

in a sequence diagram, 597sequence number, 603status, 598to self, 598

meta (Qt)object code, 862object compilation, 859, 862, 1043

method, 30invocation

asynchronous, 601synchronous, 601

MFC, 791, 844MI (C++), 721Microsoft Foundation Classes, 791, 844min element (C++), 182minimum

capacity increment, 197size recommendation, 815

minimumSizeHint() (Qt), 837MI Utilities.h (C++), 752Mixin.cc, 762mixin class, 721, 760–761

INDEX 1181

mixing C and C++, 488mm.mysql, 1059mm.mysql.Driver, 1070moc (Qt), 1043

compiler, 859, 862monitor, 979, 984monitoring

image loading, 915of a port by a server, 1032

most-derived object (C++), 736Motif, 791–792, 794MOUSE CLICKED (AWT/Swing), 914mouseClicked() (AWT/Swing), 914mouseDoubleClickEvent() (Qt), 923MOUSE DRAGGED (AWT/Swing), 914mouseDragged() (AWT/Swing), 914MOUSE ENTERED (AWT/Swing), 914mouseEntered() (AWT/Swing), 914MouseEvent

(AWT/Swing), 845, 852–853, 914–915(Qt), 923

mouse event, low-level, 923MOUSE EXITED (AWT/Swing), 914mouseExited() (AWT/Swing), 914MouseListener (AWT/Swing), 853, 913MouseMotionListener (AWT/Swing), 853, 914MOUSE MOVED (AWT/Swing), 914mouseMoved() (AWT/Swing), 914mouseMoveEvent() (Qt), 919, 923MOUSE PRESSED (AWT/Swing), 913mousePressed() (AWT/Swing), 913MOUSE PRESSED (AWT/Swing), 914mousePressed() (AWT/Swing), 914mousePressEvent() (Qt), 919, 923MOUSE RELEASED (AWT/Swing), 914mouseReleased() (AWT/Swing), 914mouseReleaseEvent() (Qt), 923MuliJmp.cc, 387MultiConstructors.java, 421MultiCustomerAccount.c, 1015MultiCustomerAccount.cc, 1022MultiCustomerAccount.java, 985multilevel return in C, 386multimap, a C++ container class, 149, 151multiple

inheritance (C++), 3, 75, 721triggers (UML), 613

multiplicity, 592for attributes (UML), 595

MultiPolymorphism.java, 683multiprocessing, 611, 963multiset, a C++ container class, 150multithreading, 611

for animation, 990versus multiprocessing, 963

mutable, 134

mutating algorithm (C++), 182mutex (POSIX)

fast, 1011kind, 1010lock, 1010recursive, 1011

mutual exclusion for thread synchronization, 1010MyDrawPanel.cc, 867MyDrawPanel.h (Qt), 867MySQL, 1058

terminal monitor, 1063Mysql++, 1075, 1057mysqladmin, 1058mysqld, 1058MyString, 506MyString.cc, 514MyTextPanel.cc, 865MyTextPanel.h (Qt), 865

N

NAME, 938name

conflict, 619, 730, 747, 749hiding (C++), 619, 671lookup (C++), 619, 671

argument-dependent, 70lookup (Java), 671mangling (C++), 69, 386, 488

NameConflictDataMem.cc, 750NameConflictMemFunc.cc, 747nameless namespace, 361NameLookup.cc, 671NameLookup.java, 671namespace (C++), 9, 61

alias, 304global, 386nesting, 67qualified name, 303scope, 303std, 22, 386unnamed, 69

Namespace.cc, 62Namespace2.cc, 65Namespace3.cc, 65Namespace4.cc, 66namespace.h (Qt), 921NamespaceNested.cc, 67�����

, Not a Number, 222narrowing

conversion (Java), 228primitive conversion (Java), 228

Narrowing.java, 231NATIONAL CHARACTER(n) (SQL), 1061native

GUI toolkit, 792threads, 964

1182 INDEX

natural (Java)comparison method, 81ordering, 80, 137, 183, 579

navigability (UML), 592nested

block, 304class

(C++), 84(Java), 84, 89, 93, 571

enumeration (C++), 89interface (Java), 84, 89, 93namespaces (C++), 67, 304typedef (C++), 84

NestedInterface.java, 93NestedClassAsType.java, 90NestedClass.cc, 84NestedClassDefsNotInline.cc, 85NestedClass.java, 89NestedTypes.cc, 88network

programming, 2-transparent computing, 790

newa C++ header file, 8–9(C++), 34, 113, 299, 333, 443(Java), 38, 131, 334(UML), 599

new[] (C++), 333, 520newConnection() (Qt), 1045newline character, 215next-element operation, 150next() (Java), 1071, 186, 190nextToken() (Java), 205, 27no-arg constructor

(C++), 43, 288, 307, 419, 507, 623(Java), 47, 312–313, 669

NoArgMissing.cc, 419Nocase (C++), 208NoCopyOnReturn.cc, 359NONE (AWT/Swing), 826nonmutating algorithm (C++), 182nonrealtime scheduling, 1004nontype parameter

template declaration (C++), 563NoPen (Qt), 921NORTH (AWT/Swing), 810, 827NORTHEAST (AWT/Swing), 827NORTHWEST (AWT/Swing), 827noshowpoint, a stream manipulator (C++), 254noskipws, a stream manipulator (C++), 255NoSuchMethodError (Java), 408notify() (Java), 984notifyAll() (Java), 983–984NOT NULL (SQL), 1062nparams (GNOME/GTK+), 880npos (C++), 120

null, 293pointer (C++), 298

NullPointerException (Java), 409NumberFormatException (Java), 18NUMERIC (SQL), 1061numeric

a C++ header file, 8escape

(C++), 215(Java), 218

types (Java), 223

O

OBJECT tag (HTML), 947Object

(Java), 75, 79, 446, 547, 984Management Group, 588

objectcloning (Java), 457deserialization (Java), 279destruction

(C++), 54, 441(Java), 446

finalization (Java), 55, 446–447reference, 329

(C++), 329(Java), 332

serialization (Java), 279ObjectIO.java, 280ObjectInputStream (Java), 280ObjectOutputStream (Java), 280oct, a stream manipulator (C++), 253octal

escape, 215integer

literal, 221notation, 221number, 216

ODBC, 1059ofstream (C++), 21–22OMG, 588one-argument constructor (C++), 535on-line Java documentation, 3OO, 1, 29

design, 3Open DataBase Connectivity, 1059openmode (C++), 239open source, 1058, 795operation (UML), 590, 595

modifier, 596query, 596

operator, 211’()’ (C++), 176arity, 498, 504binary, 499equality (C++), 513

INDEX 1183

for dereferencing (C++), 519for member access (C++), 520function (C++), 498insertion (C++), 9left bitwise shift (C), 9output (C++), 9overload definition

global (C++), 498member function (C++), 501

overloading (C++), 53, 497decrement operator, 529for derived class, 628increment operator, 529key points, 497�

for sorting, 540precedence, 497relational (C++), 513scope (C++), 89token, 498unary, 504

operator���

() (C++), 628ORDER BY (SQL), 1067, 1069ostream

a C++ header file, 8a C++ output stream class, 237

ostream iterator (C++), 206ostringstream (C++), 257ostrstream (C++), 257out (C++), 239OutOfMemoryError (Java), 408OutputIterator (C++), 566output

operator (C++), 9stream

classes (C++), 237classes (Java), 264manipulators (C++), 252object (C++), 8object (Java), 13standard (C++), 239standard (Java), 265

OutputStream (Java), 259, 989, 1029overload

resolution, 345(C++), 369(Java), 371

Overload.java, 372Overload2.java, 382OverloadBinaryGlobal.cc, 500OverloadBinaryMemb.cc, 501overloading

constructor(C++), 366(Java), 371

function name, 345(C++), 366, 368

(Java), 371of operators (C++), 497

OverloadUnaryGlobal.cc, 504OverloadUnaryMemb.cc, 505OverrideAccessRestrict.cc, 653OverrideAccessRestrict.java, 674override definition for a function, 44OverrideExceptionRestrict.cc, 654OverrideReturnRestrict.cc, 652overriding

a function(C++), 46(Java), 47

function(C++), 651(Java), 670restrictions (C++), 651restrictions (Java), 673

P

pack() (AWT/Swing), 800, 810, 813, 817, 819,822, 828, 1000

packagediagram (UML), 588, 604(Java), 3, 13, 55, 57, 71

qualified name, 56padding

(GNOME/GTK+), 838variable

ipadx (AWT/Swing), 827ipady (AWT/Swing), 827

paint() (AWT/Swing), 903–904, 916paintBorder() (AWT/Swing), 903paintChildren() (AWT/Swing), 903paintComponent() (AWT/Swing), 854, 903–904,

942paintEvent() (Qt), 918–919, 924pair, 176pallet, 798pane (AWT/Swing)

content, 797glass, 797–799layered, 797–798root, 797

Panel (AWT/Swing), 936, 948parameterization, 549parameterized

class(C++), 550, 555(Java), 568

function (C++), 550interface (Java), 573method (Java), 576

parameter list (UML), 596PARAM tag (HTML), 939, 954parseInt() (Java), 17–18, 939

1184 INDEX

pass argument to function, 345by pointer (C++), 345by reference (C++), 345by value

(C++), 345of object reference (Java), 345

pass by pointerclass type argument (C++), 351primitive type argument (C++), 347

pass by referenceclass type argument (C++), 352primitive type argument (C++), 349

pass by valueclass type argument

(C++), 350(Java), 354

of object reference (Java), 354primitive type argument

(C++), 346(Java), 353

PassClassTypeByPointer.cc, 351PassClassTypeByRef.cc, 352PassClassTypeByValue.cc, 350PassClassTypeByValue.java, 354passing arguments

(C++), 346(Java), 353

PassPrimByPointer.cc, 347PassPrimByRef.cc, 349PassPrimByValue.cc, 347PassPrimByValue.java, 353peek() (C++), 15–16, 246peer class (AWT/Swing), 793peered component (AWT/Swing), 794peerless component (AWT/Swing), 793performance penalty

for polymorphic function (C++), 650Photoshop, 795pipe (C++), 23PipedInputStream (Java), 259, 988, 990PipedOutputStream (Java), 259, 988, 990pixmap, 896PlainDocument (AWT/Swing), 854Point (AWT/Swing), 915pointer

to C++ function, 374to class member (C++), 463type (C++), 297

PointerDirectToMember.cc, 464polyline, 924, 932Polymorph.cc, 45polymorphic

behavior, 638type (C++), 646, 781

PolymorphicTypes.cc, 782polymorphism, 3, 29, 31, 682, 728, 918

in simulated OO in C, 98Polymorph.java, 48pop back() (C++), 154, 174pop() (C++), 174–175pop front() (C++), 168port, 1027–1028

number, 1027–1028Portable Operating System Interface, 1002POSIX, 1002

thread attributes, 1003threads, 964

pos() (Qt), 924precedence of an operator, 497precision

of output (C++), 252of SQL data types, 1061

preemptive scheduling, 964PretendGiant.cc, 520previous() (Java), 186PRIMARY KEY (SQL), 1061

NOT NULL, 1060–1061primitive type, 211printf() (C), 6–7, 98, 796print() (Java), 13, 265println() (Java), 13, 265PrintObj.cc, 53PrintObj.java, 52print representation (Java), 52printStackTrace() (Java), 410PrintStream (Java), 13, 265PrintWriter (Java), 265, 1034priority-preemptive scheduling, 964priority queue, a C++ container class, 149, 151,

176PriorityQueueOps.cc, 177priority of a thread, 964private

base (C++), 618class derivation (C++), 664for access control, 34, 38, 71, 595

PrivateConstructor.cc, 420Promo.cc, 224promotion, 224property-string (UML), 595–596protected

base (C++), 618class derivation (C++), 664for access control, 71, 595inheritance, 665

prototype (C++), 346pseudorandom, 460pseudorandom numbers, 56pthread attr init() (POSIX), 1003pthread attr t (POSIX), 1002–1003PTHREAD CANCELED (POSIX), 1007pthread condattr t (POSIX), 1013

INDEX 1185

pthread cond broadcast() (POSIX), 1014pthread cond destroy() (POSIX), 1014pthread cond init() (POSIX), 1013pthread cond signal() (POSIX), 1014pthread cond timedwait() (POSIX), 1014pthread cond t (POSIX), 1013pthread cond wait() (POSIX), 1014PTHREAD CREATE DETACHED (POSIX),

1003PTHREAD CREATE JOINABLE (POSIX), 1003pthread create() (POSIX), 1002pthread detach() (POSIX), 1004pthread exit() (POSIX), 1007PTHREAD EXPLICIT SCHED (POSIX), 1004PTHREAD INHERIT SCHED (POSIX), 1004pthread join() (POSIX), 1003, 1006pthread mutexattr getkind np() (POSIX), 1011pthread mutexattr setkind np (POSIX), 1011pthread mutex destroy() (POSIX), 1013PTHREAD MUTEX FAST NP (POSIX), 1010pthread mutex lock() (POSIX), 1010, 1014PTHREAD MUTEX RECURSIVE NP (POSIX),

1011pthread mutex unlock() (POSIX), 1010, 1014PTHREAD SCOPE PROCESS (POSIX), 1004PTHREAD SCOPE SYSTEM (POSIX), 1004pthread setschedparam() (POSIX), 1004pthread setschedpolicy() (POSIX), 1004pthreads.h (POSIX), 1002pthread t (POSIX), 1002public

base (C++), 618class, 11class derivation (C++), 617for access control, 34, 38, 71, 595

pull-down menu, 881pure virtual (C++), 74–75, 643, 660, 727push() (C++), 174–175push back() (C++), 153–154, 174push front() (C++), 168put() (C++), 21, 247putback() (C++), 246putc() (C), 19, 21put position (C++), 240

Q

qapplication.h (Qt), 831–832, 834, 836QApplication (Qt), 795, 801, 859

for default initializations, 795QBrush (Qt), 920QButton (Qt), 795QColor (Qt), 921QDialog (Qt), 795, 836qdialog.h (Qt), 832, 836QDns (Qt), 1038QFileDialog (Qt), 795

QFrame (Qt), 795QFtp (Qt), 1038QGrid (Qt), 830, 834qgrid.h (Qt), 834QGridLayout (Qt), 830, 835, 960QGridLayoutTest.cc, 836QGridTest.cc, 834QGroupBox (Qt), 795QHBox (Qt), 795, 830qhbox.h (Qt), 831QHBoxLayout (Qt), 830QHBoxLayoutTest.cc, 832QHBoxTest.cc, 831QLabel (Qt), 795QLayout (Qt), 795, 830qlayout.h (Qt), 832, 836, 864QLineEdit (Qt), 960QMainWidget (Qt), 802QMatrix (Qt), 919QMouseEvent (Qt), 919qmultilineedit.h (Qt), 865QMultiLineEdit (Qt), 886QMutex (Qt), 1019QNetworkProtocol (Qt), 1038Q OBJECT (Qt), 862, 870QObject (Qt), 795, 859, 870qpainter.h (Qt), 864QPainter (Qt), 918, 921QPaintEvent (Qt), 918QPoint (Qt), 924QPopupMenu (Qt), 888qpushbutton.h (Qt), 831–832, 834, 836QPushButton (Qt), 804, 836, 960QServerSocket (Qt), 1038, 1044qsizepolicy.h (Qt), 867QSizePolicy (Qt), 866QSocket (Qt), 795, 1038qsort()

(C), 116(C++), 199, 375

Qsort.cc, 117QStatusBar (Qt), 795QString (Qt), 1038Qt

a class, 921a GUI toolkit, 790–791, 793, 795

QThread (Qt), 1018QT THREAD SUPPORT (Qt), 1019quantum, 967queue

a C++ container class, 149, 151, 175a C++ header file, 8

Query (Mysql++), 1075–1076query() (Mysql++), 1076QueueOps.cc, 175quick-sort, 116, 197, 315

1186 INDEX

Q UINT16 (Qt), 1038QUIT (SQL), 1067quit(), (Qt), 804, 859QUrlOperator (Qt), 1038QVBox (Qt), 795, 830, 834QVBoxLayout (Qt), 830, 834QWaitCondition (Qt), 1022QWidget (Qt), 795, 919, 923qwidget.h (Qt), 864

R

race condition, 1006, 967Random (Java), 460random() (Java), 55–56, 460RandomAccessFile (Java), 259, 266, 273RandomAccessIterator (C++), 566–568range

checking (Java), 134violation (Java), 135

rangeCheck() (C++), 529rbegin() (C++), 565RCP, 1028read() (Java), 17–18, 24, 27, 884Reader (Java), 259, 1029, 1033read for binary I/O (C++), 247ReadIntFromFile.java, 271readInt() (Java), 271readLine() (Java), 205, 1029readObject() (Java), 280read-only collection (Java), 200read-only iterator (Mysql++), 1077readString(), 18ReadStringFromFile.java, 273readUTF() (Java), 273readyRead() (Qt), 1038, 1046realizing a component (AWT/Swing), 797, 1000REAL (SQL), 1061realtime scheduling, 1004recursive mutex (POSIX), 1011red-black tree, 191reference, 38, 329

(C++), 292initialization, 330

(Java), 332initialization, 333

handler thread (Java), 965Reference.cc, 338Reference2.cc, 339ReferenceClassType.cc, 331reflexive association (UML), 593registering

a callback, 844a listener (AWT/Swing), 847image with tracker (AWT/Swing), 915

reinterpret cast (C++), 234, 781relational

database, 1056–1057operator, 513

release() (C++), 525reliable connection-based stream protocol, 1028Remote Call Procedure, 1028remove()

(C++), 170(Java), 183, 186, 190, 206

removeAll()(AWT/Swing), 943for emptying a Java container, 183

removeElement() (Java), 196remove if() (C++), 206removeUpdate() (AWT/Swing), 854rend() (C++), 565RenderGraphics.c, 928RenderGraphics.cc, 921RenderGraphics.java, 905rendering, 903repaint()

(AWT/Swing), 904, 910, 941, 1000(Qt), 919

repeated inheritance (C++), 729, 751RepeatInherit.cc, 755replace()

(C++), 120, 567(Java), 140

reserve() (C++), 157reset(), 920RESET QUERY (SQL), 1076resize() (C++), 124, 153, 157resizing behavior, 825responsibility (UML), 592restart() (Java), 941restrictions on overriding function

(C++), 651(Java), 673

Result (Mysql++), 1075–1076ResultSetMetaData (Java), 1071resurrecting unreferenced objects, 449retrieval command (SQL), 1062return-type (UML), 596revalidate() (AWT/Swing), 943, 1000reverse() (C++), 567reverse iterator (C++), 568rfind() (C++), 120right attach (GNOME/GTK+), 840right bitwise shift operator, 16rigid area (AWT/Swing), 815rlogin, 1028Robot.cc, 427Robot.java, 434role

(UML), 588, 592-based class hierarchy, 768playing class, 721, 768

INDEX 1187

RolePlayers.cc, 771root pane (AWT/Swing), 797rotate() (Qt), 920rotating a shape, 910RotatingRect.java, 911rounding-modes for floating-point, 227round

-robin scheduling, 1004, 964-toward-zero mode, 227

RTTI (C++), 234, 646, 690, 700, 780–781run()

(Java), 966(Qt), 1018

Runnable (Java), 969runnable state, 967, 970running state, 970RuntimeException (Java), 408run-time type identification (C++), 234, 646, 690,

700, 780

S

safe mysqld, 1058SansSerif, 908SCALE DEFAULT (AWT/Swing), 916SCALE FAST (AWT/Swing), 916scale() (Qt), 920SCALE REPLICATE (AWT/Swing), 916SCALE SMOOTH (AWT/Swing), 916scaling an image, 916scanf() (C), 15SCHED FIFO (POSIX), 1004SCHED OTHER (POSIX), 1004schedparam (POSIX), 1004schedpolicy (POSIX), 1004SCHED RR (POSIX), 1004scheduling

a thread, 964, 967, 970policy, 1004priority, 1004

schema, 1073scientific, a stream manipulator (C++), 254scope, 54, 61, 283

(C++), 303(Java), 305block

(C++), 303(Java), 305

file (C++), 303for thread scheduling contention (POSIX), 1004function (C++), 303function-prototype (C++), 303namespace (C++), 303of a global identifier (C++), 304operator (C++), 36, 61, 89, 304, 619

for nested type, 89ScopeTest.java, 306

Scrollable (AWT/Swing), 940, 942scrollbar, 873, 940, 942search

for array element (Java), 315for character (Java), 139for substring (C++), 120for substring (Java), 139

second (C++), 179security, applet, 936, 956seek() (Java), 266–267seekp() (C++), 240seekg() (C++), 240SELECT (SQL), 1060, 1062, 1064SelfRef.cc, 436self-reference

(C++), 435(Java), 439

sequencecontainer

(C++), 150, 173, 565(Java), 183adapter (C++), 173

diagram (UML), 597sequential I/O, 266Serializable (Java), 75–76, 274, 279serial version UID (Java), 279server, 1027

-based database, 1057ServerSocket (Java), 1031Set, a Java container class, 182–183, 189set

a C++ container class, 149, 180a C++ header file, 8functions (SQL), 1069(Java), 182–183, 189

setBorder() (AWT/Swing), 810, 813, 819setCoalesce() (Java), 941setColor() (AWT/Swing), 905, 908setContentPane() (AWT/Swing), 798setfill(), a stream manipulator (C++), 253setHorizontalTextPosition() (AWT/Swing), 810,

813, 819setInitialDelay() (Java), 941setjmp (C), 386setjmp.h (C), 386setLayout() (AWT/Swing), 799setLocation() (AWT/Swing), 797, 810, 813, 817,

819, 822, 828, 937setMainWidget() (Qt), 832, 834, 836setMargin() (Qt), 831setMatrix() (Qt), 919–920setMaximumSize()

(AWT/Swing), 815(Qt), 833

setMinimumSize()(AWT/Swing), 815

1188 INDEX

setMnemonic() (AWT/Swing), 850SetOps.cc, 180SetOps.java, 190setPen() (Qt), 921setprecision(), a stream manipulator (C++), 252setPreferredSize() (AWT/Swing), 815setPriority() (Java), 967setSize() (AWT/Swing), 800, 937setSocket() (Qt), 1046setSpacing() (Qt), 831setToolTipText() (AWT/Swing), 849setVerticalTextPosition() (AWT/Swing), 810, 813,

819, 822setVisible() (AWT/Swing), 797, 810, 813, 817,

819, 822, 828, 1000setw(), a stream manipulator (C++), 253setWorldMatrix() (Qt), 920shape rendering, 918short, 213, 220short-circuit evaluation (C++), 543SHOW (SQL), 1065show()

(AWT/Swing), 1000, 797(Qt), 801–802, 831–832, 834, 836

showbase, a stream manipulator (C++), 254showDocument() (Java), 956showpoint, a stream manipulator (C++), 254shuffle, 150, 166shuffle() (Java), 316side effect, 347SIGNAL (Qt), 859signal, 870

(C++), 804emission, 844emitted by button, 808

signaling object, 1013signal name (GNOME/GTK+), 880signals and slots (Qt), 844SignalSlotLCD.cc, 860signature

function, 369signed

char (C++), 213–214int (C++), 213, 221

Silly.cc, 376Simple Mail Transfer Protocol, 1028SimulatedOO.c, 98simulated OO in C, 2, 790–791Singleton.cc, 417singleton (Java), 200Singleton.java, 416size()

(C++), 124, 175, 180(Java), 190

sizeHint() (Qt), 833, 836–837sizeof, 6–7, 98, 117, 125

sizePolicy() (Qt), 837, 866size t (C++), 110, 120size type (C++), 116, 119, 122Sketch.c, 933Sketch.cc, 924sketching, free-form, 923, 932skipws, a stream manipulator (C++), 255Skipws.cc, 256sleep state, 964, 970SlideShowApplet.html, 946SlideShowApplet (Java), 940SlideShowApplet.java, 943SLOT (Qt), 859slot (Qt), 804, 844, 870, 887SMALLINT (SQL), 1061SmallInt (C++), 529SmallIntWithIncrDecr.cc, 531smart pointer (C++), 519SmartPtr.h, 527SmartPtrInitial.cc, 523SmartPtrWithOwnership.cc, 525SMTP network service, 1028society of objects, 1Socket (Java), 1028–1029, 1038socket, 1027–1028, 1038

number, 1027–1028SolidLine (Qt), 921sort()

(C++), 116, 162, 171, 182, 206, 375, 538, 567,692

(Java), 55, 137, 145, 185–186, 205, 315pointer types (C++), 542stable, 117

SortedMap, a Java container class, 184, 191SortedSet, a Java container class, 183sort heap() (C++), 567SortPointerTypes.cc, 542SortTiming.java, 55SortWithFunctor.cc, 539SortWithLessThan.cc, 540SOUTH (AWT/Swing), 810, 827SOUTHEAST (AWT/Swing), 827SOUTHWEST (AWT/Swing), 827SpecialInt.cc, 437SpecialInt.java, 440specialization, 769specification perspective (UML), 592specificity, 369splicing one list into another

(C++), 171(Java), 185–186

SQL, 1055, 1057, 1059sstream, a C++ header file, 8, 257stable sorting, 117, 197, 315Stack, a Java container class, 184stack, 299

INDEX 1189

a C++ container class, 149, 151, 174a C++ header file, 8(Java), 184

stacking order, 842StackOps.cc, 174StackOverflowError (Java), 408standard

conversion, 224–225error stream, 239, 21, 23input stream, 239namespace (C++), 9output, 8

stream, 23, 239StandardConvert.cc, 225Standard Template Library (C++), 8–9start()

for applets (AWT/Swing), 903, 937, 991for QThread (Qt), 1018for Thread (Java), 966for Timer (Java), 941

startsWith() (Java), 141state

diagram (UML), 604of input stream object (C++), 23transition (UML), 606

state() (Qt), 1039statechart diagram (UML), 588, 606

concurrent, 608Statement (Java), 1070static, 19, 595, 690

class member(C++), 422(Java), 430

const (C++), 422initialization, 422

destruction (C++), 429final (Java), 430, 690

initialization, 430for continuous storage (C++), 362for file scope (C++), 361initialization (C++), 429member, 81

initialization (C++), 423, 426initialization (Java), 433

nested class (Java), 89, 847result set (Mysql++), 1077variable (C++), 361binding (C++), 647

Static1.cc, 422Static1.java, 430Static2.cc, 423Static2.java, 431StaticBinding.cc, 647static cast (C++), 117, 232, 618, 781StaticStorage.cc, 362status message in sequence diagram (UML), 598

stddef.h (C), 110stderr, standard error stream (C), 19, 21stdexcept, a C++ header file, 8–9stdin, standard input stream (C), 14stdio.h, a C header file, 21stdlib.h, a C header file, 20std, standard namespace (C++), 9, 22, 386stereotype (UML), 596STL (C++), 8–9stop()

for applets (AWT/Swing), 937for Timer (Java), 941

store() (Mysql++), 1076storage allocation

String (Java), 132strcat() (C), 110strcmp() (C), 109, 563strcpy() (C), 98, 110, 507stream

buffering(C++), 258(Java), 264

function (C++), 252hierarchy

(C++), 237(Java), 259

manipulator (C++), 252streambuf (C++), 258

a header file, 8strerror() (C), 1003stretch (Qt), 833String (Java), 18String

(Java), 129storage allocation, 132

string(C), 108(C++), 33, 113(Java), 129a C++ header file, 8–9, 113, 116constant, 108constructor

(C++), 507(Java), 131

joining of(C), 110(C++), 111(Java), 138

literal, 108, 211::npos (C++), 120stream, 257

StringBuffer (Java), 38, 129StringCharIndexing.cc, 114StringFind.cc, 121StringFind.java, 140string.h, a C header file, 107, 109

1190 INDEX

StringIndexOutOfBoundException (Java), 134StringInsert.java, 141StringLiteralUniqueness.java, 131StringSize.cc, 125StringSizeOf.cc, 127StringSort.java, 137StringTokenizer (Java), 26, 192, 205strlen() (C), 109, 507struct

(C), 98(C++), 336

access privilege, 337tag, 336

StructInit.cc, 337Structured Query Language, 1055, 1057StyledDocument (AWT/Swing), 854subclass, 2, 31

(C++), 42copy assignment operator, 617copy constructor, 617operator overloading, 617

(Java), 47subscript operator (C++), 150substr() (C++), 122substring() (Java), 141superclass, 31

(C++), 42(Java), 47

super (Java), 47super() (Java), 670superstate (UML), 608suppressing name mangling (C++), 386swap() (C++), 129Swap.cc, 356Swap.java, 355SwapWithPointer.cc, 357Swing (Java), 790–791SwingUtilities (AWT/Swing), 993, 1000switch, 305sync() (C++), 258SynchedFileIO.java, 981SynchedSwaps.c, 1011SynchedSwaps.cc, 1019SynchedSwaps.java, 979synchronization

bar (UML), 611(C++), 1019(Java), 979pthreads (POSIX), 1010

synchronizedcollection (Java), 200container (Java), 185

synchronizedList() (Java), 200synchronous method invocation, 601System (Java), 13, 56, 957

system thread group (Java), 965

T

tab character, 215TableLayoutTest.c, 841TCP, 1028

server socket, 1038socket, 1038

tellg() (C++), 240, 248tellp() (C++), 240telnet, 1027, 1053

daemon, 1027telnetd, 1027template

class, 547class (C++), 83declaration (C++)

general syntax, 563nontype parameter, 563type parameter, 563

parameter, 555parameter (C++)

default value, 564list, 563

specialization (C++), 560TemplateX.cc, 83templatization, 549templatized

class, 550, 568function, 550program, 548

terminate() (C++), 393TermIO.c, 14TermIO.cc, 15TermIO.java, 17TestFilePosition2.cc, 241TestFilePosition.cc, 240Text, 1059TextArea (AWT/Swing), 882, 884text string, drawing of, 919TFTP, 1028TFTP network service, 1028this, for self-reference

(C++), 435, 453(Java), 439

this() (Java), 421, 669Thread (Java), 1018, 941, 966, 968thread

grouptree (Java), 965

interference, 971priority, 942, 964safety, 1000scheduling

first-in first-out, 1004nonrealtime, 1004

INDEX 1191

priority-preemptive, 964round-robin, 1004, 964

stateblocked, 970born, 967, 970dead, 970runnable, 967, 970running, 970sleeping, 970waiting, 970

synchronization(C++), 1019(Java), 979(POSIX), 1010

ThreadBasic.c, 1005ThreadBasic.java, 966ThreadBasicWithJoin.c, 1007ThreadBasicWithJoin.java, 968ThreadBasicWithRunnable.java, 969ThreadGroup (Java), 965Throwable (Java), 399throw clause (C++), 389throwing multiple exceptions, 404throws clause (Java), 399time order in a sequence diagram (UML), 601Timer (Java), 940, 943timeslicing of threads, 964, 967, 972TIME (SQL), 1061

WITH TIME ZONE, 1061TIMESTAMP (SQL), 1061

WITH TIME ZONE, 1061toArray() (Java), 183, 201, 316token, 192, 211toolbar, 798, 897Toolkit (AWT/Swing), 794, 915top() (C++), 174top attach (GNOME/GTK+), 840top-level

containers, 793, 795–796window, 796, 804

toString() (Java), 52tower of GUI API’s, 792transient (Java), 281transition, statechart diagram (UML), 606transitivity, 605translate()

(AWT/Swing), 905(Qt), 920

translating Unicode into UTF-8, 270Transmission Control Protocol, 1028transparent pixels, 793TreeMap, a Java container class, 184, 191TreeSet, a Java container class, 189trigger (UML), 612trimToSize() (Java), 197Trivial File Transfer Protocol, 1028

trunc (C++), 239try–catch

(C++), 389(Java), 18, 24, 401

TryCatch.cc, 390TryCatch.java, 400two’s complement representation, 230, 236type, 114

conversionexplicit, 223explicit (C++), 232, 234explicit (Java), 234for primitive types, 223implicit, 223implicit (C++), 224, 232implicit (Java), 228

typedef (C++), 61, 65–67, 69, 84, 88, 113, 169,237

typeid() (C++), 786typeinfo, a C++ header file, 8–9type

inheritance (C++), 665parameter, 555

constraining of (Java), 579template declaration of (C++), 563

typename (C++), 563

U

UDP, 1028ugetc() (C), 14UML, 3, 588unary operator, 504unchecked exception (Java), 399, 408unexpected() (C++), 393unget() (C++), 246ungetc() (C), 15Unicode, 134, 136, 213, 218, 237, 1029Unified Modeling Language, 3, 588UNIQUE (SQL), 1062unique() (C++), 171Unix, 791–792, 794–795

emulation in Windows, 12UnknownHostException (Java), 1029unmodifiableList() (Java), 200unnamed namespace (C++), 69, 304unsigned

char (C++), 213–214int, 110, 116int (C++), 213long int, 110

UnsupportedEncodingException (Java), 134UnsynchedFileIO.java, 976UnsynchedSwaps.c, 1008UnsynchedSwaps.java, 972upcasting (C++), 628–629UPDATE (SQL), 1060, 1062, 1066

1192 INDEX

update()(AWT/Swing), 904(Qt), 919

URL, 939, 943, 953, 1028, 1038(Java), 956

usage patterns for exception handling(C++), 391(Java), 402

US-ASCII, 133USE (SQL), 1063use case (UML), 588, 608

diagram, 588extend relationship, 590generalization, 590include relationship, 590

User1.cc, 35User2.cc, 35User3.cc, 36UserConv.cc, 534UserConvConstructor.cc, 535UserConvExplicit.cc, 536User Datagram Protocol, 1028User.java, 39using (C++)

declaration, 64, 303directive, 9, 22, 61, 64, 303

UTF-8, 133encoding, 270

UTF-16, 133UTF-16BE, 133UTF-16LE, 133–134utility, a C++ header file, 8, 176

V

valarraya C++ container class, 150, 152a C++ header file, 8

VARCHAR(n) (SQL), 1061variable

default initialization, 283(C++), 286(Java), 293

Vector, a Java container class, 184, 194vector

(C++), 567(Java), 184, 194a C++ container class, 148, 150, 152, 174a C++ header file, 8, 156initialization (C++), 157, 166migration, 149

VectorBasic.cc, 155VectorForClassType.cc, 164VectorFrontBackResize.cc, 157VectorInitArray.cc, 167VectorInsertEraseSort.cc, 160VectorListOps.java, 196

VectorOps.java, 195VERTICAL (AWT/Swing), 826viewport view, 816virtual

base (C++), 237, 731, 737, 752destructor (C++), 655, 727, 781function (C++), 44, 617, 638, 651, 918pure (C++), 74–75, 643, 727table (C++), 648

pointer, 649terminal, 791

VirtualBase.cc, 732VirtualBaseAssign.cc, 740VirtualBaseCopyConstruct.cc, 737VirtualDestructor.cc, 655VirtualPrint1.cc, 641VirtualPrint2.cc, 644visibility, 43, 47, 595

private, 595protected, 595public, 595

visual representation, 587VSPACE, 938vtbl (C++), 648vtpr (C++), 649VtprConcealed.cc, 649

W

waitlist, 984state, 964, 970

wait()(C++), 1018(Java), 983–984

waitForAll() (AWT/Swing), 915waitForID() (AWT/Swing), 915wait–notify (Java), 983wait–signal (POSIX), 1014wait–wake (Qt), 1022wakeAll() (Qt), 1022wakeOne() (Qt), 1022weightx (AWT/Swing), 826weighty (AWT/Swing), 826WEST (AWT/Swing), 810, 827WHERE (SQL), 1062white-space characters, 15–16, 212Widening.java, 228widening primitive conversion (Java), 228widening type conversion (Java), 371widget, 795Win32, 793

API, 791–792WINDOW ACTIVATED (AWT/Swing), 852WindowAdapter (AWT/Swing), 680, 850WINDOW CLOSED (AWT/Swing), 852windowClosing() (AWT/Swing), 850

INDEX 1193

WINDOW CLOSING (AWT/Swing), 852windowClosing() (AWT/Swing), 852WINDOW DEACTIVATED (AWT/Swing), 852WINDOW DEICONIFIED (AWT/Swing), 852WindowEvent (AWT/Swing), 852WINDOW ICONIFIED (AWT/Swing), 852WindowListener (AWT/Swing), 847window manager, 842WINDOW OPENED (AWT/Swing), 852Windows platform, 794WindowWithButtons2.java, 850WindowWithButtons.java, 848WindowWithHelloButton.c, 871WindowWithMenu.c, 898WindowWithMenu.cc, 889WindowWithMenu.h (Qt), 889WindowWithMenu.java, 884wistream (C++), 258wostream (C++), 258wrapper class (Java), 185, 194

WriteBinaryIntsToFile.cc, 250writeBytes() (Java), 269writeChars() (Java), 264, 270writeDouble() (Java), 264writeFloat() (Java), 264write for binary I/O (C++), 247writeInt() (Java), 264WriteIntToFile.java, 261write() (Java), 24, 262–263, 269writeObject() (Java), 280Writer (Java), 259, 1029, 1033WriteStringToFile.java, 267writeUTF() (Java), 270wxWindows (C++), 791

X

Xlib, 791–792Xt, 791X window system, 790