Index

A

abort() function, 361, 365

Abstract base classes (ABCs)

assignment operators in, 332–334, 337–339

core of the program structure, 56

for interfaces, 487

protected assignment operators in, 332–333

pure virtual destructors for, 298

pure virtual member functions for, 296

Abstract states, const for, 199–200

Abstraction

bad, 76–77

in C vs. C++, 543

classes for, 81

vs. encapsulation, 76

importance of, 75

interfaces for, 79

user-centric, 75–76

using friends for, 253–254

Access control

defaults for struct vs. class, 250–251

derived class access to base class members, 242–243, 250, 549–550

friends and. See Friend classes and functions

private, protected, and public, 249

Active Directory, 524

ActiveX controls

definition, 519–520

events for, 522–523

vs. OCXs, 520–521

ActiveX technology, 482–483

Adaptable specifications, 92, 99–100

AddRef() method

in COM, 489

in DCOM, 523

errors from, 500

Addresses of references, 159

adjacent_find() operations, 395

Advertised requirements and promises

changes in, 90–91

and exceptions, 136–139

and inheritance, 95

in specifications, 54–55, 86–92

Aggregation

vs. private and protected inheritance, 547–548

purpose of, 69–70

syntax for, 246

Algorithms, templates for, 343

Aliases. See also References

const with, 203–204

namespace, 215

Aliasing and self-assignment, 328–329

Alive objects, 67

Allocating memory

for arrays, 173–174

with new. See operator new

with placement operator new, 285–286

Allocations, pointers to, 440

Analysis and design method, 49

Angle brackets (<>) for templates, 25

Anonymous enums, 228

Apprenticeships, 562–563

Architectural perspective, 51

changing customer requirements, 54–55

and domain analysis, 58

flexibility, 59

frameworks, 55–57

importance of architecture, 52

problem domain, 53

problem policy, 53–54

reuse, 59–60

supporting change, 58

Argument Lists

variable-length, 431–432

Arguments. See also Parameters

for default constructors, 275–277

for dual interfaces, 518–519

in initialization lists, 312–313

template, copying, 349–351

Arity of operators, 325

Arrays

allocating and deallocating, 173–175, 180–181

in C vs. C++, 564

vs. containers, 388

destruction of elements in, 271

initialization lists for, 313–314

passing, 126–127

of pointers, 556–557

vs. vectors, 25

assert statements

for behavioral self-testing, 146

for class invariants, 149–150

Assignment operators

in abstract base classes, 332–334

and the Big Three, 415–416, 420–421, 429

in derived classes, 335–336, 339–340

overloading, 320–321

partial assignments with, 330–332

placement new and copy constructors for, 341

return values for, 327–328, 334–335

and self-assignment, 328–330

synthesized, 335, 418–419

virtual, 337–340

Associative containers, 398–399

Associativity of operators, 325

Asymmetry with variable-length argument lists, 431–432

Asynchronous events, 523

Attaching references to referents, 156

Authentication in DCOM, 524

auto objects

basics of, 13–14

destruction of, 271, 278–281

in inline functions, 184

in inner scopes, 17–18

references to, 157–158, 452

auto_ptr<T> class

with containers, 391

for handling remote ownership, 424–426

safety of, 34–35

auto references, 157–158

Automation

and ActiveX controls, 520

and COM, 509–510

dispatch interfaces with, 510–512

and events, 523

operation of, 512–513

type libraries for, 515

Automation Marshaler, 512

automation proxy classes, 513

B

bad_alloc exception, 167–168

Base class subobjects, 545

Base classes, 240

abstract. See Abstract base classes (ABCs)

access to, 242–243, 250, 549–550

converting derived class pointers to, 245

destructors for, 278

and downcasting, 376–378

hiding rule for, 405–407

protected interface of, 243–244

Based object approach, 373–374

Basic Object Adapter (BOA), 533

Behavior

abstraction of, 81

in inheritance, 95, 117

Behavior-centric view, 81

Behavioral self-testing, 146–148

Best of breed approach, 392–393

Big-endian byte ordering, 531

Big Three

and auto_ptr<T>, 426–428

definition, 415–416

law of, 420

need for, 420–421, 428–429

noninlining, 429–430

for referents, 422–423

for remote ownership, 421

Bilingual header files, 538–540

Binary object models, 483–484

binary_search() operations, 397

Binary specification of COM interfaces, 488, 498–499

Binding

for dual interfaces, 516

dynamic. See Dynamic binding

and final member functions, 473

reference variables to temporary objects, 455–456

type libraries and, 516

Birds, ostriches, 104–106

Bitwise copying

problems with, 166, 430–431

in variable-length argument lists, 431–432

Bitwise states, const for, 199–200

Block boundaries, pointers across, 453

Blue-collar programming, 560

BOA (Basic Object Adapter), 533

Books for transition to C++, 561–562

Boolean inspectors, 79

Bottlenecks

determining, 462

tuning, 78

Braces ({}) and local object destruction, 278–281

Browsers, type libraries for, 515

Buffers for streams, 22

Bug fixes, exception specifications with, 131

Built-in types

assignment operators for, 419

copy constructors for, 417–418

destructors for, 416–417

Business-centric perspective, 44

Business frameworks, 50

Business goals, 45, 47

Byte orderings, 531

C

C language considerations

access to C++ objects, 540–541

calling C++ code, 537–538

code called by C++, 536–537

compatibility with C++, 64–65

I/O with, 541–542

linker errors, 538

mixing with C++, 535

passing C++ objects, 538–540

transition to C++, 564–565

Cache coherency, 202

Caches

for performance, 463, 468

reducing misses in, 187

Call-back handlers, pointers passed to, 555–556

Call-through member functions, 546

Calling

C code, 536–537

C++ code from C, 537–538

constructors, 270, 277

destructors, 271

new code from old, 72–74

static member functions, 226

Capability queries, 373

Casts. See also Downcasts

in C vs. C++, 564

dynamic_cast<T>() for, 381–383

for pointers, 455, 551

static_cast<T>() for, 383

catch keyword, 38

Catching exceptions, 359–360

basics of, 37–39

guidelines for, 353–356

rethrows after, 354–356

Categories, component, 522

CATIDs (Category Identifiers), 486, 522

cerr stream, 22

Chain reactions caused by wild pointers, 451–452

Changes

and const references, 203–204

in customer requirements, 54–55

designed from the beginning, 63–64

fear of, 89–90

preventing, with const, 194–195

specifications for, 89–91

support for, 58

in synchronizing specifications with code, 93

char type and containers, 390

Child classes, 240

cin stream, 22–23

Circles, inheriting from ellipses, 111–115

Clarity, using throw/catch for, 132–133

Clashes, name. See Namespaces

Class data, 218

Class Identifiers (CLSIDs)

for ActiveX controls, 520

in COM, 485–486

Class invariants

for testing, 149–150

for wild pointers, 151–152

class keyword vs. struct keyword, 250–251

Class services, 218

Classes

advantages of, 68–69

base. See Abstract base classes (ABCs); Base classes

behavioral self-testing for, 146

in COM, 485, 492–496, 505–506, 508–509

in COM+, 524–526

constructors for, 29–31

defining, 27–28, 508–509

derived. See Derived classes

destructors for, 31–32

for exceptions, 141

final, 471–474

header files for, 26–27

importance of, 66

instantiated, 345

naming, 485

in object-oriented programming, 65, 68–69, 81

with overloaded operators, 24

with pointers to heap objects, 32–35

printing objects in, 267–268

private, 266–267

purpose of, 81

templates for. See Templates

Cleverness, evilness of, 47

CLSIDs (Class Identifiers)

for ActiveX controls, 520

in COM, 485–486

CoCreateGuid() routine, 487

CoCreateInstance() function, 496–497

Code

danger of using as a specification, 84–86

exception safe, 17, 441

final object duplication of, 476–478

for finding code, 370–371

reusing. See Reuse

sharing. See Templates

size of, with inline functions, 185–188

substitutability not based on, 99–100

synchronizing specification with, 92–93

for type-safe downcasts, 384

CoGetClassObject() function, 496

Cohesion, friends and, 255

COM (Component Object Model)

architecture of, 483

Automation and, 509–510

as a binary object model, 483–484, 488, 498–499

vs. C++, 504–507

classes and objects in, 485, 492–496, 505–506, 508–509

COM+, 524–526

component categories in, 522

vs. CORBA, 534

creating and using objects in, 496–498

DCOM, 523–524

definition, 481–482

dispatch interfaces in, 510–514

dual interfaces in, 516–519

error handling in, 501, 506

features of, 484–485

GUIDs in, 485–487

interface versioning in, 502–503

interfaces in, 487–492

IUnknown interface in, 488–490

language transparency in, 498–499

location transparency in, 499–500

object orientation of, 503

problems with, 504

reference counting in, 500–501

type libraries in, 514–516

COM+, 524–526

COM servers, 496

Comments

for advertised requirements and promises, 87–89

for final classes, 472

for initialization list order dependency, 311–312

for memcpy(), 351

Common Object Services (COS), 528

comp.lang.c++ news group, 6

Compatibility

of C++, 64–65

for C/C++ mixed applications, 535

of inline functions, 189

in interface versioning, 502–503

Compilers

assignment operators synthesized by, 335, 418–419

for C/C++ mixed applications, 535

copy constructors synthesized by, 417–418

destructors synthesized by, 416–417

maximal munch rule used by, 351–352

Completeness in specification reliance, 85

Complexity

created by capability queries, 373

created by reuse concerns, 52

intelligent objects handle, 68

interface/implementation separation for handling, 77

unnecessary, 46

virtual functions for handling, 372

Component Object Model. See COM (Component Object Model)

Components in COM, 481–483, 522

Composition

vs. private and protected inheritance, 547–548

purpose of, 69–70

syntax for, 246

Compound Documents, 482

Comprehensibility, object-oriented programming for, 71

Concrete derived classes, 241–242

Conflicts

abstract states, 199–200

aliases, 203–204

code efficiency, 195

in COM vs. C++, 507

for formal parameters, 200–201

GUIDs for avoiding, 486–487

importance of, 196–197

for inspector functions, 28, 197–198

for member functions, 198–199

with mutable data members, 202

namespaces for avoiding. See Namespaces const

overhead of, 195

pass-by-reference, 19

for pointers, 193

for return types, 201–202

for type safety, 195–196

const_cast

for data members, 202–203

and optimization, 204–205

const correctness, 194–197

const data members, initializing, 227–228, 305

const references, 163

parameters passed by, 456–457

returned by template functions, 457

Construct on first use semantics, 233, 237

Construction

member object exceptions during, 357–359

operator new for, 165

Constructors

calling, 270, 277

class invariants for, 150

in COM vs. C++, 505

copy. See Copy constructors

declaring, 29–31

default, 15, 275–277

with empty bodies, 303–305

exceptions thrown by, 356

with explicit parameters, 15

for final classes, 472

initialization lists for. See Initialization lists

named, 225–226, 281–282

purpose of, 269–270

return codes, 132

virtual, 291–293

virtual functions called by, 283–284, 293–295

Consultants, 560

Containers

vs. arrays, 388

associative, 398–399

auto_ptr<T> with, 391

basics of, 24–26

best of breed approach for, 392–393

of char, 390

creating, 388–389

definition, 387

dynamic type checking with, 373–374

homogeneous vs. heterogeneous, 392

improper inheritance, 119–126

Java-type objects for, 391

mistakes with, 387–388

of pointers, 389–391

sequence, 394–398

standardized, 393–394

Context in business decision-making, 44

Controllers for exception handling, 354

Controls

containers for, 521–523

OCX and ActiveX, 519–523

Converting derived class pointers to base class, 245

Cookie cutters, templates as, 343

Copy constructors

and assignment operators, 341

Big Three and, 415–416, 420–421

invoking, 274–275

purpose of, 273–274

synthesized, 417–418

Copy-on-write semantics, 443–449

copy() sequence operations, 395–396

Copying

bitwise, 166, 430–432

with memcpy(), 430–431

template arguments, 349–351

variable-length argument lists, 431–432

CORBA (Common Object Request Broker Architecture)

vs. COM, 534

concepts in, 530

definition, 527

exceptions in, 533–534

IDL in, 531–532

importance of, 529–530

object life cycle in, 532

portability of, 533

CORBA Services (COS), 528

COS (Common Object Services), 528

Cost/benefit analyses, 59

CoStack, 492–493

count() operations, 395

Counter, nifty idiom, 235–238

Counting, reference. See Reference counting

Coupling, minimizing, 77

Courses for transition to C++, 562

cout stream, 21–22

CPU bound applications, 462–463, 465–467

CPU costs of type-safe downcasts, 384

Crash sources

exception handling, 365

exceptions, 168

memcpy(), 430–431

realloc(), 432

static data member initialization order, 231–234

variable-length argument lists, 431–432

wild pointers, 452

CreateInstance() function, 496

Ctors. See Constructors

Custom COM interfaces, 488

Custom marshaling in COM, 500

Customers, requirement changes by, 54–55

Customization technique, 479

D

Dangling pointers, 331

Dangling references

DCOM, 523

from parameters, 306, 456–457

wild pointers, 451

Data-centric view of object-oriented programming, 81

Data encryption in DCOM, 524

Data marshaling in DCOM, 524

Data members

in COM+, 525

get/set member functions for, 80–81

initializing, 269–270

mutable keyword for, 202

naming convention, 28

Data structures, templates for, 343

Data transformation in CORBA, 531

Data types

checking. See Dynamic type checking

in IDL, 531

Database bound applications, 462–463

DCE (Distributed Computing Environment), 524

DCE IDL (Distributed Computing Environment Interface Definition Language), 484

DCOM (Distributed COM)

infrastructure of, 524

purpose of, 523–524

Dead objects, 67

Deallocating resources

arrays, 173–175, 180–181

exceptions from, 361

Death by one thousand cuts syndrome, 46

Debugging

inline functions, 183

voodoo, 151

Decisions in business, 44

Declarations

performance of, 470–471

for pointers, reading, 193

using, 210, 213

Declaring

arrays of pointers, 556–557

assignment operators, 332–333

COM classes, 504

constructors, 29–31

destructors, 31–32

formal parameters, const for, 200–201

friend functions, 265–266

inheritance, 239–240

Deep copies for remote ownership, 422

Default constructors, 15, 275–277

Default parameters, 13

DEFINE_GUID macro, 486

#define macros, 26, 183–184

Defining

classes, 27–28, 508–509

COM interfaces, 490–492

member functions, 28–29, 296

virtual destructors, 297

Definitions of inline functions, 184–185

Deinitialization of static data members, 234–237

delete operator. See operator delete

Deleted allocations, pointers to, 440

Deleting

arrays, 174, 181

pointers, 167, 172–173

this object, 179–180

deque<T> class, 394

Derived class arrays, passing, 126–127

Derived classes

assignment operators in, 335–336, 339–340

base class member access by, 242–243, 250, 549–550

casting pointers to, 551

concrete, 241–242

destructors for, 278

downcasts to, 376–378

and final classes, 471–472

hiding rule for, 405–407

inheritance, 70, 239–242

pointers to base classes in, 245

using the base class’s protected interface, 243–244

using syntax for, 409–411

Design factors in performance, 461–462

Design notations, 49

Design tools, 49–50

Destruction of objects

array elements, 271

in COM vs. C++, 506

local objects, 271, 278–281

placement new, 177–178

recording, 429

in throw/catch process, 131

Destructors

and Big Three, 415–416, 420–421, 429

calling, 271

in COM vs. C++, 505

declaring, 31–32

of derived classes, 278

exceptions caught by, 359–360

exceptions thrown by, 359

execution of, 272–273

for local objects, 14, 278–281

for placement new objects, 177–178, 286

purpose of, 271

for static data members, 234–235

synthesized, 416–417

virtual, 289–290, 297–298

virtual functions called by, 284, 293–295

Developer-centric abstraction, 75–76

Development, inline functions during, 190

Development costs in creating containers, 388

discard() function, 169

Dispatch interfaces

in COM, 510–514

in dual interfaces, 516–518

DISPIDs, 516

dispinterface statement, 512

Distributed COM (DCOM)

infrastructure of, 524

purpose of, 523–524

Distributed Computing Environment (DCE), 524

Distributed Computing Environment Interface Definition Language (DCE IDL), 484

DllRegisterServer() routine, 520

DllUnregisterServer() routine, 520

DNS (Domain Name System), 524

Documentation, class invariants for, 149–150

Domain analysis

faulty, 58

improper inheritance from, 111, 114

Domain model, 55

Domain Name System (DNS), 524

Domain-specific frameworks, 56–57

Domino effect with wild pointers, 451–452

Downcasts

alternatives to, 378–380

costs of, 384–385

with derived classes, 376–378

and inheritance graphs, 380–381

problems with, 380

with RTTI. See RTTI (runtime type identification)

Dtors. See Destructors

Dual interfaces

in COM, 516–518

limitations on, 518–519

Dummy parameter for operator++, 321–322

Duplication of code from final objects, 476–478

Dynamic binding

advantages of, 71

basics of, 39–41

for calling new code from old, 72

vs. dynamic type checking, 371–372

virtual functions with, 288–289

dynamic_cast<T>() function

misusing, 383

purpose of, 381–382

vs. typeid(), 384

Dynamic type checking

alternatives to, 371–372

avoiding, 371

with containers, 373–374

definition, 368–370

and inheritance, 97

necessity of, 374

problems with, 370–371

Dynamically allocated objects, 16–17

Dynamically typed languages, 455

E

Efficiency of const, 195

Electronic FAQ, 6

Elements, container, 387

Ellipse, circle inheriting from, 111–115

Empty constructor bodies, 303–305

Encapsulation

vs. abstraction, 76

constructors for, 270

and friends, 256

Encryption in DCOM, 524

#endif statements, 26

endl, 22

enum for const static data members, 228

equal() operations, 395

Error Reporting technology, 482

Errors and error handling. See also Exceptions and exception handling

in COM, 501, 506

by constructors, 356

mistakes in, 129

with pointers, 556

in reference counting, 500–501

return codes for, 132, 501

Events

for ActiveX controls, 522–523

in COM+, 525

Exception Handling technology, 482

Exception safe code, 17, 441

Exceptions and exception handling. See also Errors and error handling

and advertised requirements, 86–87

basics of, 37–39

catching, 353–356, 359–360

classes for, 141

in COM+, 525

from constructors, 356

in CORBA, 533–534

crashes related to, 365

from destructors, 359

from functions, 137–139

hierarchy of, 140

in IDL, 531

memory leaks due to, 178–179

with operator new, 167–168

from overridden virtual functions, 106–108, 363–365

purpose of, 130

with resource management, 361, 437–438

separating from normal logic, 133–136

specifications for, 131

terminate() function, 361

throwing, 136–139

try block, 353

unexpected() function, 361–363

and zombie objects, 357

Executable code size with inline functions, 185–188

Explicit parameters, 15

Explicit specialization, 346–348

Exponentiation operator, 325

Extensibility

and dynamic type checking, 370–371

inheritance for, 97

of <iostream> vs. <stdio.h>, 542

object-oriented programming for, 71

in specification, 86

of type-safe downcasts, 385

value of, 58

Extensible frameworks, 56–57

extern C construct, 536–537

F

fill() operations, 396

Final classes and member functions, 287

code duplication from using, 476–478

definitions, 471–472

developer dislike of, 478

for performance, 471–474

find() operations, 395

Flexibility

creating, 59

interface/implementation separation for, 78–79

of <iostream> vs. <stdio.h>, 542

in object-oriented programming, 64, 71

operator new for, 166

for performance, 462

pointers and references for, 463–467

in specifications, 85

flushAllPools() function, 171

Flushing objects

I/O buffers, 22

operator new , 169–171

Focus in resource management, 437

for_each() operations, 395

Forests in inheritance graphs, 380–381

Formal parameters, const for, 200–201

Fragmentation of memory, 467–468

Frameworks

definition, 55–56

extensible and domain-specific, 56–57

inversion of control in, 56

management perspective on, 50

free() function, 166

Freestores

performance, 463

reducing, 467–468

Friend classes and functions

advantages of, 255

class invariants in, 151

declaring, 265–266

definitions, 253–254, 256–257

and encapsulation, 256

guidelines for, 258

mental models for, 255

for printing class objects, 267–268

for private classes, 266–267

qualities of, 263–265

for readability, 257

static data function similarities to, 224

for stream input, 268

virtual, 261–263

Friendship

inheritance of, 260–261

transitivity of, 258–260

Fully qualified names

for member function calls, 475–476

for virtual function calls, 474–475

Function call operator for functionoids, 230–231

Functionoids

function call operator for, 230–231

for maintaining states, 229–230

Functions

basics of, 12–13

vs. classes, 68–69

default parameters for, 13

exception throwing by, 137–139

friend. See Friend classes and functions

inline. See Inline functions

member. See Member objects

templates for, 348–349

virtual. See Virtual functions

G

Garbage collection

in DCOM, 523

in Java, 391

generate() operations, 396

Genericity, 343

Get/set member functions

for data members, 80–81

in interfaces, 80

GetIDsOfNames() method, 513, 516

Global objects

basics of, 35–36

namespaces for, 215

static data member similarities to, 224

Globally Unique Identifiers (GUIDs)

definition, 485–486

need for, 486–487

for type libraries, 514

Glue code

for passing C++ objects with C functions, 538–540

in piecewise reuse, 56

Goals

business, 45

and object-oriented programming, 47

Granularity in performance, 462

Groupings, namespaces for, 208

Grunt programming, 560

GUI events for ActiveX controls, 523

guidgen.exe utility, 487

GUIDs (Globally Unique Identifiers)

definition, 485–486

need for, 486–487

for type libraries, 514

H

Handling errors. See Exceptions and exception handling

Hardware transparency in ORB, 528

Has-a relationships

composition for, 69–70

vs. private and protected, 548

Header files

bilingual, 538–540

for C code, 536–537

creating, 26–27

Heap and heap allocation

operator new for, 16–17

placement operator new for, 285–286

pointers to, 32–35

Heap corruption

from arrays, 174, 181

from Big Three law violations, 420

from pointers, 167, 172–173

Heterogeneous objects

containers, 392

dynamic type checking for, 374

Hiding

friend classes for, 255

inherited member functions, 100–101

and inline functions, 189

Hiding rule

definition, 404–407

handling, 407–409

with virtual functions, 411

Hierarchies

copy-on-write semantics for, 446–449

of exceptions, 140

in frameworks, 55

Homogeneous containers vs. heterogeneous, 392

HRESULT values, 501

Human issues in reuse, 59–60

I

IClassFactory interface, 495–496, 520

ICreateTypeInfo interface, 515

ICreateTypeInfo2 interface, 515

ICreateTypeLib interface, 515

ICreateTypeLib2 interface, 515

ID binding, 516

Identically defined inline functions, 185

IDispatch interface

for Automation, 512–513

for dual interfaces, 517–518

IDL definition for, 511–512

Invoke method in, 513–514

IDL (Interface Definition Language)

vs. C++, 531–532

for COM libraries, 514

in CORBA, 529–530

definition, 528

for dispatch interfaces, 511–512

for dual interfaces, 517

IErrorInfo interface, 525

#ifdef statements

for behavioral self-testing, 146

for class invariants, 150

#ifndef statements, 26

IIDs (Interface Identifiers) in COM, 485

for dual interfaces, 517

for IUnknown, 490

IIOP (Internet Inter-ORB Protocol), 530

Implementation

changes in, 89

of COM classes, 504

of COM interfaces, 492–496

interface separation from, 77–79

reliance on, 84–86

substitutability based on, 99–100

Implementation inheritance in COM+, 525

Implementation transparency in ORB, 528

Improper inheritance

avoiding, 104

circles from ellipses, 111–115

for code reuse, 117–119

with containers, 119–126

definition, 97–98

due to bad domain analysis, 111, 114

due to bad intuition, 104

in kind-of relationships, 104–106

problems from, 103

vs. proper, 98

stacks from lists, 115–117

includes() operations, 397

Incoherent object states, 430

Increment operations, prefix vs. postfix, 321–323, 468–469

Incremental approach to namespaces, 208

Indirection layers, 463

Industry thought leaders, 560

Inheritance

basics of, 39–41

for calling new code with old, 72

in COM+, 507, 525

declaring, 239–240

with derived classes, 70, 239–242

of friendship, 260–261

hiding rule for, 407–408

improper. See Improper inheritance

with kind-of relationships, 245

in object-oriented programming, 65, 70

private and protected, 246–247, 545–551

proper. See Proper inheritance

purpose of, 70

using syntax for, 409–411

Inheritance graphs

forests, 381

shape of, 380

Initialization

constructors for, 29–31, 269–270

operator new for, 165

references attached during, 156

of static data members, 220–221, 227–228, 231–234

Initialization lists, 31

argument screening in, 312–313

for arrays, 313–314

for const data members, 305

definition, 301–302

and empty constructor bodies, 303–305

guidelines for, 303

order in, 306–309, 311–312

for performance, 302–303

for reference data members, 306

and this object, 309–312

Inline functions

deciding on, 188–189

executable code size with, 185–188

vs. inline keyword, 184

one-definition rule for, 185

performance of, 183–187, 189

purpose of, 183–184

rules for, 184–185

static data member access by, 220–221

swapping with non-inline, 190–192

third party, 189

for virtual destructors, 297

for virtual functions, 299–300

Inner scopes, local objects in, 17–18

Input, stream

basics of, 22–23

for user defined classes, 268

Inspector functions, 28

boolean, 79

capability queries, 373

const for, 197–198

Instance data members, 217–218

Instantiated classes, 345

Instantiation of templates, 345–346

int return value for main(), 12

Intelligent objects, 67–68

Interception in COM+, 525

Interface definition in COM, 484

Interface Definition Language. See IDL (Interface Definition Language)

Interface Identifiers (IIDs) in COM, 485

for dual interfaces, 517

for IUnknown, 490

interface statements, 517

Interfaces

for abstractions, 79

changes in, 89

in COM+, 525

defining, 490–492

definition of, 487–488

dispatch, 510–514, 516–518

dual, 516–519

get/set member functions in, 80

implementation separation from, 77–79

IUnknown, 488–490, 492–494, 520

naming, 485

versioning, 502–503

Internet Inter-ORB Protocol (IIOP), 530

intersection in sequence operations, 397

Intuition, improper inheritance from, 104

Invariants

for detecting wild pointers, 151–152

in testing, 149–150

Inversion of control in frameworks, 56

Invoke method

in IDispatch, 513–514

Invoking copy constructors, 274–275

I/O bound applications, 462–463

I/O buffers with streams, 22

<iostream> header

for cin, 22

for cout, 21

extensibility of, 542

flexibility of, 542

mixed with <stdio.h>, 541

safety of, 541–542

IPersistStream interface, 520

IPersistStreamInit interface, 520

Is-a conversions, 40–41

Is-a relationships, 117

Is-substitutable-for relationships, 117

IStack interface, 492–495, 511

ITypeInfo interface, 515

ITypeInfo2 interface, 515

ITypeLib interface, 515

ITypeLib2 interface, 515

IUnknown interface

for ActiveX controls, 520

in COM, 488–490

implementation of, 492–494

J

Java-type objects for containers, 391

Java vs. C++, 49

K

Keyed containers, 398–399

Kind-of relationships, 117, 240

improper inheritance in, 104–106, 119–126

inheritance for, 70, 245

Koenig lookup, 212–213

L

Language independence

of COM, 482

of CORBA, 530

of MIDL, 491

Language transparency in COM, 484, 498–499

Late binding, type libraries for, 516

Late life-cycle performance tuning, 462

Leaf classes and member functions, 287

definitions, 471–473

for performance, 471–474

Leaks. See also Resource management

auto_ptr<T> for preventing, 426–428

due to exceptions, 178–179

importance of, 433–434

preventing, 434–436

LIBIDs (Type Library Identifiers), 486, 514

Libraries

for COM, 504, 514–516

management perspective on, 50

name clashes in. See Namespaces

Life cycle of CORBA objects, 532

Linked lists, 387

Linking

in C/C++ mixed applications, 535

in OLE, 482–483

Linking errors

with C code called by C++, 538

from static data members, 227

Lists

initialization. See Initialization lists

linked, 387

stacks inheriting from, 111–115

variable-length argument lists, 431–432

list<T> class, 394

Little-endian byte ordering, 531

Local objects

basics of, 13–14

destruction of, 271, 278–281

in inline functions, 184

in inner scopes, 17–18

references to, 452

Local references, 157–158

Location transparency

in COM, 484, 499–500

in ORB, 528

Long identifiers, namespaces for, 215

Long-term costs in creating containers, 389

longjump statements

with destructors, 271

throw/catch process in place of, 141

lvalues for references, 158–159

M

Macros

in COM, 491

for inline functions, 183–184

for recompile the world problem, 190

vs. templates, 343

main() function

basics of, 11–12

in C/C++ mixed applications, 535

inlining, 185

Maintaining states, functionoids for, 229–230

Maintenance

class invariants for, 149–150

programming for, 47

self-testing objects for, 145–146

Maintenance costs

from changes, 90

and inheritance, 98

of type-safe downcasts, 384

malloc() function

vs. new, 165–166

with operator delete, 166

Managed pointers, 424–426, 434–436, 441–442

Management perspective, 43

business-centric vs. techno-centric, 44

business goals, 45

class libraries and frameworks, 50

complexity, 46

object-oriented programming, 47–49

processes and tools, 49–50

Software Peter Principle, 47

map<Key, Value> container class, 398

Marshaling

in COM, 500

in DCOM, 524

for dual interfaces, 517

type library, 512, 516–517

Matrix-like classes, subscript operators for, 323–324

Maximal munch rule, 351–352

Mechanisms for frameworks, 57

Member objects, 545

advertised requirements and promises in, 86–91

call-through to, 546

class invariants in, 150

in COM+, 525

const for, 198–199

defining, 28–29, 296

destruction of, 271

exceptions thrown in constructor by, 357–359

final, 471–474

fully qualified names for, 475–476

get/set member functions for, 80–81

initialization lists for, 301–302, 305–306

initializing, 269–270

inspector and mutator, 28

mutable keyword for, 202

for performance, 467–468

pointers to, 553–557

in proper inheritance, 100–101

specification fulfillment by, 91–92

virtual. See Virtual functions

Memberwise operations

assignment, 419

copy construction, 417–418

destruction, 416–417

memcpy() function

crashes from, 430–431

for template arguments, 349–351

Memory

efficient use of, 64

positioning objects in, 175–176

Memory allocation

for arrays, 173–174

with new. See operator new

with placement operator new, 285–286

Memory fragmentation, reducing, 467–468

Memory leaks. See also Resource management

auto_ptr<T> for, 426–428

from exceptions, 178–179

importance of, 433–434

preventing, 434–436

Memory space bound applications, 462–463

Mentors for transition to C++, 562–563

Meta data

in COM, 485, 506

in COM+, 525

Methods

class, 218

in COM+, 525

Microsoft Interface Definition Language (MIDL), 484

advantages of, 491–492

for dispatch interfaces, 511–512

Microsoft Message Queueing, 523

Microsoft Transaction Server, 523

MIDL (Microsoft Interface Definition Language), 484

advantages of, 491–492

for dispatch interfaces, 511–512

min_element() operations, 398

mismatch() operations, 395

Models

in COM, 483–484

in frameworks, 55

Modules

vs. classes, 68

in IDL, 531

Monolithic hierarchy of exceptions, 140

Monolithic trees in inheritance graphs, 381

multimap<Key, Value> container class, 398

Multiparadigm language, C++ as, 64

Multiple inheritance, 507

multiset<T> container class, 398

mutable keyword, 202

Mutating sequence operations, 395–397

Mutator functions, 28

class invariants in, 150

vs. inspector, 197–198

N

Name conflicts

in COM vs. C++, 507

GUIDs for avoiding, 486–487

namespaces for avoiding. See Namespaces

Named constructor idiom, 225–226, 281–282

Names

in COM, 485, 505

for exception classes, 141

of operators, 325

Namespaces, 207

applications of, 215

code breaking by, 213–214

duplicate names in, 210–211

for long identifiers, 215

name lookup for, 212–213

rules for, 211–212

techniques for, 213

using declarations for, 209–210, 213

Naming services in DCOM, 524

Nesting

functions, 463

namespaces, 208

Network bound applications, 186, 462–463

New code, calling with old code, 72–74

new handlers, 171

new operator. See operator new

newline character, 22

Nifty counter technique, 235–238

NIH (not invented here) syndrome, 388

No-op virtual functions, 109–110

Noninlining Big Three, 429–430

Nonmutating sequence operations, 395

Nonstatic member functions, pointers to, 553–557

Nonsubstitutable changes, 89–91

Not invented here (NIH) syndrome, 388

nothrow keyword, 168

NULL pointers, 457–459

operator delete with, 172

operator new with, 167–168

O

Object class in Java, 391

Object Management Architecture (OMA), 528

Object Management Group (OMG), 529

Object-oriented programming, 559–560

abstraction in, 75–76

apprenticeships for, 562–563

architecture in, 51

behavior-centric view of, 81

books for, 561–562

and business goals, 47

C experience when learning, 564–565

C++ benefits for, 64–65

classes in, 65, 68–69, 81

and COM, 503

composition in, 69–70

courses for, 562

for flexible and extensible software, 71

fundamental concepts of, 65

get/set member functions in, 80–81

ignoring, 48

inheritance in, 70

interface separated from implementation in, 77–79

languages for, 48–49

objects in, 66–68

for old code calling new code, 72–74

polymorphism and dynamic binding in, 71

skills for, 565–566

small projects for learning, 563–564

stages of technical expertise in, 560–561

transition to, 63–64

Object Request Broker (ORB), 527–528

Objects

aliases for. See References

assignment operators for, 418–419

in COM, 483, 492–498, 506

in COM+, 525

copy constructors for, 417–418

in CORBA, 532

creating and using, 176–177, 496–498

definition, 66–67

destructors for, 416–417

dynamically allocated, 16–17

in object-oriented programming, 65

operator new for, 165, 176–177

passing. See Passing objects

pointers managed by, 434–436, 441–442

positioning in memory, 175–176

printing, 267–268

qualities of, 67–68

self-testing. See Self-testing objects

stream input for, 268

in throw/catch process, 131

zombie, 357

OCXs (OLE Custom Controls), 482

vs. ActiveX, 520–521

definition, 519–520

Old code, calling new code with, 72–74

OLE (Object Linking and Embedding), 482–483

OLE Automation, 482

OLE Compound Documents, 482

OLE Custom Controls (OCXs), 482

vs. ActiveX, 520–521

definition, 519–520

OLE2, 482–483

OMA (Object Management Architecture), 528

OMG (Object Management Group), 529

One-definition rule for inline functions, 185

Online FAQ, 6

operator()

for functionoids, 230–231

for subscripts, 323–324

operator++, prefix vs. postfix, 321–323, 468–469

operator<<

cout, 22

namespaces, 212–213

for printing class objects, 267–268

operator>> for stream input, 268

operator delete

with arrays, 174–175

with malloc(), 166

with pointers, 167, 172

with this object, 179–180

operator new

with arrays, 174

basics of, 16–17

creating objects with, 176–177

vs. malloc(), 165–166

NULL pointers with, 167–168

placement new. See Placement operator new

pointers with, 166–167

pooling objects with, 169–171

positioning objects with, 175–176

purpose of, 165

Operator overloading

for exponentiation, 325

for matrix-like class subscripts, 323–324

vs. normal functions, 315–316

operator++, 321–323

operator new, 166

for readability, 316–317

restrictions on, 317–318

subscript operators, 319–320

for user benefit, 318

user expectations in, 320–321

Operators, assignment. See Assignment operators

Optimization

const_cast effects on, 204–205

inline functions for, 186–187

ORB (Object Request Broker), 527–528

Order of initialization, 231–234, 306–312

Organizational goals, 45

OSF, GUIDs in, 485

Ostriches inheriting from birds, 104–106

Out-of-process objects in COM, 507

Out-of-process servers, type libraries for, 515

Output, stream, 21–22

Overhead

of const, 195

final objects reducing for, 473–474

inline function savings, 186

of return codes, 132

of self-testing objects, 145

of virtual functions, 288

Overloading

in COM+, 525

with const, 198, 201

in IDL, 532

operators. See Operator overloading

vs. overriding, 403–404

using syntax in, 409–411

virtual functions, 411–413

Overridden virtual functions

exceptions thrown by, 106–108, 363–365

no-op, 109–110

Overriding

in IDL, 532

vs. overloading, 403–404

virtual assignment operators, 339–340

Ownership

with containers of pointers, 389–391

of friend functions, 258

remote, 421–422, 424–426

in resource management, 437

P

Packages, Java version of namespaces, 208

Packaging of COM classes, 509

Page faults, reducing, 186–187

Parameterized types, 343

Parameters. See also Arguments

const for, 200–201, 456–457

for constructors, 30–31

default, 13

explicit, 15

for heap allocation, 285–286

for templates, 344

Parent classes, 240

Parentheses () for parameters, 15

Partial assignments, 330–332

partition() operations, 397

Passing objects

arrays, 126–127

to C functions, 538–540

by pointer, 20–21

pointers to nonstatic member functions, 555–556

by reference, 18–19, 155–156

by value, 19–20

Perception, friend functions for, 265

Performance

of C++, 64

of COM, 509

of declarations, 470–471

design factors in, 461–462

final objects for, 471–474

initialization lists for, 302–303

of inline functions, 183–187, 189

interface/implementation separation for, 78–79

member objects for, 467–468

pointers and references for, 463–467

prefix increment operations vs. postfix, 468–469

of programming languages, 478–479

pure virtual destructors for, 298

of standardized containers, 393

techniques for, 462–463

tuning, 78, 462

type libraries for, 516

Persistent heterogeneous objects, 374

Peter Principle, Software, 47

Piecewise reuse, 56

Pinging in DCOM, 523

Placement operator new, 175–176

for assignment operators, 341

destroying objects created with, 177–178

purpose of, 285–286

Planning for change, 55

Platform independence

in CORBA, 530

in IDL, 531

Plus operator, overloading, 320–321

POA (Portable Object Adapter), 533

Pointer variables, safe state for, 440–441

Pointers

to allocations, 440

for arrays, 173–174, 388

arrays of, 556–557

across block boundaries, 453

in C vs. C++, 564

casts for, 380, 455, 551

class of referents, 374–376

in COM vs. C++, 506

containers of, 389–391

converting derived class to base class, 245

dangling, 331

degradation from, 465–467

deleting, 167, 172–173

errors with, 556

to heap objects, 32–35

in IDL, 532

managed, 424–426, 434–436, 441–442

to member functions, 553–557

need for, 161–162

NULL, 167–168, 172, 457–459

with operator new, 17, 166–168

passing objects by, 20–21

for performance, 463–465

with placement operator new, 285–286

reading declarations for, 193

reference counting with, 442–443

vs. references, 160–162, 454

and remote ownership, 421

self-assignment with, 328–329

types of, 553–554

wild, 151–152, 451–452

zeros with, 457–459

Policies in frameworks, 57

Polymorphism

advantages of, 71

for calling new code with old, 72

Portability of CORBA, 533

Portable Object Adapter (POA), 533

Position of friend functions, 263–264

Postconditions in specifications, 86–89

Postfix increment operations, 321–323, 468–469

pow() function, 325

Precedence of operators, 325

Preconditions in specifications, 86–89

Prefix increment operations, 321–323, 468–469

printf() function, 21

Printing objects, 267–268

private classes

derived class access to, 242–243, 250

friends for, 266–267

private inheritance, 246

access rules for, 549

base class access from, 549–550

casting pointers with, 551

definition, 545–546

vs. protected, 546

syntax and semantics for, 547–548

private members

assignment operators, 334

constructors for final classes, 472

in default class syntax, 251–252

friend functions, 265

vs. protected, 249, 251

vs. public, 249

Problem domain

and abstraction, 75

architecture based on, 53–54

change planning based on, 55

Problem policy, architecture based on, 53–54

Procedural integration, inline functions for, 187

Procedures, 12

Processes, management perspective on, 49–50

Profiling tools, 463

Programming by contract technique, 83

Programming languages, performance of, 478–479

Promises

and changes, 90–91

and exceptions, 136–139

in specifications, 86–92

Promotion, use for friend functions, 264

Proper inheritance

benefits of, 97

definition, 95–96

vs. improper inheritance, 98

and member function behavior, 100–101

and specialization, 101

and subsets, 102

substitutability from, 97, 99–100

Properties in COM+, 525

Proprietary containers, 393

protected inheritance, 246–247

access rules for, 549

base class access from, 549–550

casting pointers with, 551

definition, 545–546

vs. private, 546

syntax and semantics for, 547–548

protected interface for derived classes, 243–244

protected members

assignment operators, 329, 332–334

friend functions, 265

vs. private, 251

Proxies

in COM, 499–500

in CORBA, 530

MIDL for, 492

public inheritance, 245, 549

public interface

in class definitions, 27

for derived classes, 244

friend functions in, 258

public members

friend functions, 265–266

hiding rule for, 407–408

vs. private and protected, 249

Pure virtual functions

in COM, 505

defining, 296

definition of, 295–296

destructors, 298

Q

Quality costs in creating containers, 389

QueryInterface method, 489, 497

R

Raising numbers to powers operator, 325

random_shuffle() operations, 397

Readability

friend functions for, 257

operator overloading for, 316–317

Reading pointer declarations, 193

realloc() function, 166, 432

Recompile the world problem, 190

Recursive inline functions, 184

Recycled objects, flushing, 169–171

Reference counting

in COM, 489, 500–501

with copy-on-write semantics, 443–449

in DCOM, 523

errors in, 500–501

with pointer semantics, 442–443

References

addresses of, 159

attaching to referents, 156

binding to temporary objects, 455–456

changing referents for, 160

const with, 163, 203–204

counting. See Reference counting

dangling, 306, 451, 456–457, 523

definition, 155–156

initialization lists for, 306

to local objects, 157–158, 452

ownership of referents, 422–423

passing objects by, 18–19, 155–156

for performance, 463–465

vs. pointers, 160–162, 454

resistance to, 162

returning, 158–159, 452

self-assignment with, 328–329

values for, 157

Registry in COM, 485, 507

Release() method

in COM, 489, 497

in DCOM, 523

Remote ownership

classes for, 424–426

deep copies for, 422

definition, 421

Remote Procedure Call (RPC), 524

remove() operations, 396

replace() operations, 396

Requirements

changes in, 90–91

and exceptions, 136–139

and inheritance, 95

in specifications, 54–55, 86–92

Resident gurus, 560

Resource management

for arrays, 173–175, 180–181

exceptions from, 361, 437–438

for multiple resources, 438–440

principles of, 436–437

Responsibility in resource management, 437

Responsible objects, 67

Return error codes

in COM, 501

disadvantages of, 132

Return types

const for, 201–202

for constructors, 29

with dual interfaces, 518–519

Return values

for assignment operators, 327–328, 334–335

for functions, 12

for main(), 12

“Returning a reference to a local object” warning, 452

Returning references, 158–159, 452

Reuse

achieving, 59–60

complexity from concerns for, 52

inheritance for, 117–119

interface/implementation separation for, 77

piecewise, 56

templates for, 24

reverse() operations, 397

Ripple effects

from const, 196–197

interface/implementation separation for reducing, 77

object-oriented programming for reducing, 71

specifications for reducing, 86, 89–90

rotate() operations, 397

RPC (Remote Procedure Call), 524

RTTI (runtime type identification), 367–368

costs of, 384–385

definition, 381

dynamic_cast<T>() in, 381–383

static_cast<T>() in, 383

typeid() in, 383–384

Runtime CPU costs of type-safe downcasts, 384

runtime_error exceptions, 354

Runtime errors. See Exceptions and exception handling

S

Safe state for pointer variables, 440–441

Safety

of <iostream> vs. <stdio.h>, 541–542

operator new for, 165

Scalability

interface/implementation separation for, 78

in specification reliance, 86

scanf() function, 22

Scope resolution operator (::)

for constructors and destructors, 293–294

for final member functions, 473

for member functions, 295

for namespaces, 209–210

for static member functions, 226

for virtual member functions, 474–475

Scopes

hiding rule for, 405–407

local objects in, 17–18, 278–281

in object destruction, 278–281

in overloading, 403

Screening initialization list arguments, 312–313

Scripting languages, dual interfaces for, 516

SDP (software development process), 78

search() operations, 395

Security

in COM+, 525

in DCOM, 524

Self-assignment

problems with, 328–329

testing for, 329–330

Self-testing objects

advantages of, 143–144

behavioral, 146–148

classes, 146

excuses for not using, 144–145

for maintenance, 145–146

Senior developers, 560

Sequence container classes, 394–398

Server objects in CORBA, 532

Services

class, 218

classes for, 81

in specifications, 84–85

set_difference() operations, 398

set_intersection() operations, 397

set_new_handler() function, 171

set_union() operations, 397

setjump statements, 141

set<T> container class, 398

Sharing source code. See Templates

Side effects

inline functions for reducing, 186

from macros, 183–184

from static data member destructors, 234–235

from zombie objects, 357

Signal handlers, pointers passed to, 555–556

Signatures in overriding and overloading, 403–404

Size of code with inline functions, 185–188

Small projects, 563–564

Software architecture. See Architectural perspective

Software development process (SDP), 78

Software Peter Principle, 47

sort() operations, 397

Sorting sequence operations, 397

Source files

for constructors, 30

for destructors, 32

sharing. See Templates

static data members in, 36

Specialization

bad heuristic for inheritance, 101, 114

for templates, 346–348

Specifications, 83

abstraction, 75

adaptable, 92, 99–100

advertised requirements and promises in, 86–89

CORBA as, 527

for derived class member functions, 95

exception, 131

fulfillment of, 91–92

in interfaces, 487–488

for reducing ripple effect, 86, 89–90

reliance on, 84–86

substitutability based on, 99–100

substitutable change in, 90–91

synchronized with code, 92–93

Square brackets ([]) for deallocating arrays, 173, 180–181

stable_sort() operations, 397

Stack objects. See Local objects

Stack operations, reducing, 187

Stacks, inheriting from lists, 111–115

Stages of technical expertise in transition to C++, 560–561

Standard COM interfaces, 488

Standard marshaling, 500

Standardization costs in creating containers, 389

Standardized containers, 393–394

Static

global objects declared as, 35–36

Static associative arrays, 180–181

Static binding for final member functions, 473

static_cast<T>() function, 383

Static members and functions

analogies for, 218–220, 222–223

calling, 226

const, 227–228

definition, 217–218

deinitialization of, 234–237

destruction of, 271

destructors for, 234–235

friend function similarities to, 224

global variable similarities to, 224

initializing, 227–228, 231–234

inline function access to, 220–221

in inline functions, 184

linker errors from, 227

for maintaining states, 229–230

techniques for, 237–238

Static methods in COM+, 525

Static type checking, 367–368

Static typing, virtual functions with, 288–289

Status flags for zombie objects, 357

<stdio.h>

extensibility of, 542

flexibility of, 542

mixed with <iostream>, 541

safety of, 541–542

Stream input

basics of, 22–23

for class objects, 268

Stream output, 21–22

Strings, 390

structs vs. classes, 68, 250–251

Stubs

in COM, 499–500

MIDL for, 492

Subclasses, 240

Subscript operators

for matrix-like class, 323–324

overloading, 319–320

Subsets

as bad heuristic for inheritance, 102

vs. substitutability, 106

Substitutability

and inheritance, 95, 97, 99–100

vs. subsets, 106

Substitutable changes, 89–91

Super-classes, 240

swap() operations, 396

swap_ranges() operations, 396

Symbolic names for GUIDs, 485

Synchronizing specification with code, 92–93

Synthesized operations

assignment, 335, 418–419

copy construction, 417–418

destruction, 416–417

System registry in COM, 485, 507

SystemException class, 533

Systems, architecture of, 52

T

Technical expertise in transition to C++, 560–561

Techno-centric perspective, 44

Technology, management understanding of, 45–46

Templates

const references returned by, 457

for containers, 24–26, 373–374

copying arguments in, 349–351

explicit specialization for, 346–348

function, 348–349

maximal munch rule for, 351–352

for performance, 462

purpose of, 343

syntax and semantics of, 344–346

Temporary objects, binding, 455–456

terminate() function, 361, 365

Terminology in COM, 504

Testing

advantages of, 143–144

class invariants in, 149–151

for classes, 146

excuses for not using, 144–145

interface/implementation separation for, 77

for maintenance, 145–146

for self-assignment, 329–330

self-testing objects, 143–148

type-safe downcasts, 384

Third party inline functions, 189

this object

with assignment operators, 334–335

deleting, 179–180

and initialization lists, 309–312

Thrashing, 187, 462–463

Threading models, 507

Throw/catch process. See also Exceptions and exception handling

advantages of, 132–133

object destruction in, 131

vs. setjump and longjump, 141

Throwing exceptions

basics of, 37–39

decisions for, 136–139

Tight cohesion, 255

Tilde characters (~) for destructors, 31

Time benefits in specification reliance, 85

Tokenizers, maximal munch rule for, 351–352

Tools

management perspective on, 49–50

profiling, 463

Trade-offs in business decision-making, 44

Training

for synchronizing specification with code, 93

for transition to C++, 562

Transaction Server, 523

transform() operations, 396

Transition to C++, 559–560

apprenticeships for, 562–563

books for, 561–562

C experience in, 564–565

courses for, 562

skills for, 565–566

small projects for, 563–564

stages of technical expertise in, 560–561

Transitivity of friendship, 258–260

Transparency

in COM, 484, 498–500

in ORB, 528

try blocks, code in, 353

try keyword, 38

Tunability, 78

type() function, 370

type_info class, 384

Type libraries

benefits of, 515–516

in COM, 514–516

for performance, 516

Type Library Identifiers (LIBIDs), 486, 514

Type Library Marshaling, 512, 516–517

Type-safe downcasts

costs of, 384–385

for pointers, 455

Type safety, const for, 195–196

typedef statements, 554, 556–557

typeid() function, 383–384

Types

checking. See Dynamic type checking

in IDL, 531

of pointers, 553–554

U

Unbound temporary objects, destroying, 271

Underscores (_) for names of data members, 28

unexpected() function, 361–363, 365

Uniform Data Transfer technology, 482

Uninitialized pointers, 451

Unions

NULL pointers with, 458

in sequence operations, 397

unique() operations, 396

unnamed enums, 228

Usability, importance of, 52

User-centric abstraction, 75–76

User-defined classes for static data members, 36

UserException class, 533

using syntax

for derived classes, 409–411

for namespaces, 209–210, 213

V

Value

passing objects by, 19–20

for references, 157

Variable-length argument lists, 431–432

Variables in inline functions, 184

VBXs (Visual Basic Controls), 519

Vectors vs. arrays, 25

vector<T> class, 394

Vendors

for C/C++ mixed applications, 535

inline functions from, 189

Versatility costs in creating containers, 389

Versioning, interface, 502–503

Virtual assignment operators

in abstract base classes, 337–339

overriding, 339–340

Virtual base classes, destructors for, 272

Virtual constructor idiom, 291, 447

Virtual constructors, 291–293

Virtual destructors, 32

for abstract base classes, 298

Big Three, 429

defining, 297

guidelines for, 289

purpose of, 289–290

Virtual friend function idiom, 261–263

Virtual function tables in COM vs. C++, 506

Virtual functions

called by constructors, 283–284, 293–295

called by destructors, 284, 293–295

in COM, 505

in COM+, 525

definition, 287–288

vs. downcasts, 378–380

vs. dynamic type checking, 371–372

exceptions from, 106–108, 363–365

as final member functions, 473

fully qualified names for, 474–475

inline functions for, 299–300

no-op, 109–110

overhead of, 288

overloading, 411–413

overridden, 106–110

pure, 295–296, 298, 505

scope resolution operator for, 295

with static typing and dynamic binding, 288–289

Visual Basic

type libraries for, 515

vtable interfaces for, 510

Visual Basic Controls (VBXs), 519

void type

return values, 12, 27

return values for assignment operators, 334–335

Voodoo debugging, 151

vtable interfaces, 510, 516–518

W

Wild pointers

class invariants for detecting, 151–152

crashes from, 452

definition, 451

World Wide Web, ActiveX for, 520–521

Z

Zeros with pointers, 457–459

Zombie objects, 357

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset