14
PEARSON E-How SIXTH EDITION 2ROG RAM Dehe' Deitel Assodaes, Inc. M. Jute Deitel & Associates, Inc. DEHTEL° Upper Saddle River, New Jersey 07458

SIXTH EDITION - CERNcds.cern.ch/record/1515663/files/0136152503_TOC.pdf · PEARSON E-How SIXTH EDITION 2ROGRAM Dehe' Deitel Assodaes, Inc. M. Jute Deitel & Associates, Inc. DEHTEL°

  • Upload
    others

  • View
    5

  • Download
    0

Embed Size (px)

Citation preview

Page 1: SIXTH EDITION - CERNcds.cern.ch/record/1515663/files/0136152503_TOC.pdf · PEARSON E-How SIXTH EDITION 2ROGRAM Dehe' Deitel Assodaes, Inc. M. Jute Deitel & Associates, Inc. DEHTEL°

PEARSON

E-HowSIXTH EDITION

2ROGRAM

Dehe'Deitel Assodaes, Inc.

M. JuteDeitel & Associates, Inc.

DEHTEL° Upper Saddle River, New Jersey 07458

Page 2: SIXTH EDITION - CERNcds.cern.ch/record/1515663/files/0136152503_TOC.pdf · PEARSON E-How SIXTH EDITION 2ROGRAM Dehe' Deitel Assodaes, Inc. M. Jute Deitel & Associates, Inc. DEHTEL°

cp..-1...=-,

...--,

1?Tehce

f© V©M Begfin

fi

llrerrckmeicm © Complutercs, ne ggi]ercne mildne Wcrlid Wfide Wec3 g

1.1 Introduction 21.2 What Is a Computer? 41.3 Computer Organization 41.4 Early Operating Systems 51.5 Personal, Distributed and Client/Server Computing 61.6 The Internet and the World Wide Web 61.7 Web 2.0 71.8 Machine Languages, Assembly Languages and High-Level Languages 81.9 History of C and C++ 91.10 C++ Standard Library 101.11 History of Java 111.12 Fortran, COBOL, Pascal and Ada 111.13 BASIC, Visual Basic, Visual C++, C# and .NET 121.14 Key Software Trend: Object Technology 131.15 Typical C++ Development Environment 141.16 Notes About C++ and C++ How to Program, 6/e 161.17 Test-Driving a C++ Application 17

1.18 Software Technologies 231.19 Game Programming with the Ogre Libraries 241.20 Future of C++: Open Source Boost Libraries, TR1 and C++Ox 251.21 Software Engineering Case Study: Introduction to Object Technology

and the UML 251.22 Wrap-Up 301.23 Web Resources 31

llneod.mceern © C++ Prrogmanniing 432.1 Introduction 44

2.2 First Program in C++: Printing a Line of Text 442.3 Modifying Our First C++ Program 482.4 Another C++ Program: Adding Integers 49

Page 3: SIXTH EDITION - CERNcds.cern.ch/record/1515663/files/0136152503_TOC.pdf · PEARSON E-How SIXTH EDITION 2ROGRAM Dehe' Deitel Assodaes, Inc. M. Jute Deitel & Associates, Inc. DEHTEL°

x Contents

2.5 Memory Concepts2.6 Arithmetic2.7 Decision Making: Equality and Relational Operators2.8 (Optional) Software Engineering Case Study: Examining the ATM

Requirements Specification2.9 Wrap-Up

535558

6372

llrerrocumden LD Cilasseo @rnd CDbjeds 85

3.1 Introduction 82

3.2 Classes, Objects, Member Functions and Data Members 82

3.3 Overview of the Chapter Examples 84

3.4 Defining a Class with a Member Function 84

3.5 Defining a Member Function with a Parameter 88

3.6 Data Members, set Functions and get Functions 91

3.7 Initializing Objects with Constructors 98

3.8 Placing a Class in a Separate File for Reusability 102

3.9 Separating Interface from Implementation 106

3.10 Validating Data with set Functions 1123.11 (Optional) Software Engineering Case Study: Identifying the Classes in

the ATM Requirements Specification 1173.12 Wrap-Up 125

ConUoll 22ementso PaA 11 13 5

4.1 Introduction 1324.2 Algorithms 1324.3 Pseudocode 1334.4 Control Structures 1344.5 i f Selection Statement 1384.6 i f ...el se Double-Selection Statement 1394.7 whi 1 e Repetition Statement 1444.8 Formulating Algorithms: Counter-Controlled Repetition 1464.9 Formulating Algorithms: Sentinel-Controlled Repetition 1524.10 Formulating Algorithms: Nested Control Statements 1634.11 Assignment Operators 1694.12 Increment and Decrement Operators 1694.13 (Optional) Software Engineering Case Study: Identifying Class Attributes

in the ATM System 1734.14 Wrap-Up 177

Corned2M2roents g L32, g' 5 92

5.1 Introduction 1935.2 Essentials of Counter-Controlled Repetition 1935.3 for Repetition Statement 1955.4 Examples Using the for Statement 200

Page 4: SIXTH EDITION - CERNcds.cern.ch/record/1515663/files/0136152503_TOC.pdf · PEARSON E-How SIXTH EDITION 2ROGRAM Dehe' Deitel Assodaes, Inc. M. Jute Deitel & Associates, Inc. DEHTEL°

Contents xi

5.5 do ...wh i le Repetition Statement 2045.6 swi t ch Multiple-Selection Statement 2065.7 break and conti nue Statements 2165.8 Logical Operators 2185.9 Confusing the Equality (==) and Assignment (.) Operators 2225.10 Structured Programming Summary 2235.11 (Optional) Software Engineering Case Study: Identifying Objects'

States and Activities in the ATM System 2285.12 Wrap-Up 233

lunceerrus Ern ['Reedzehn Recurcsiion 2446.1 Introduction 2456.2 Program Components in C++ 2466.3 Math Library Functions 2476.4 Function Definitions with Multiple Parameters 2496.5 Function Prototypes and Argument Coercion 2546.6 C++ Standard Library Header Files 2566.7 Case Study: Random Number Generation 2586.8 Case Study: Garne of Chance; Introducing en um 2646.9 Storage Classes 2686.10 Scope Rules 2716.11 Function Call Stack and Activation Records 2746.12 Functions with Empty Parameter Lists 2786.13 Inline Functions 2796.14 References and Reference Parameters 2816.15 Default Arguments 2866.16 Unary Scope Resolution Operator 2886.17 Function Overloading 2896.18 Function Templates 2926.19 Recursion 2946.20 Example Using Recursion: Fibonacci Series 2986.21 Recursion vs. Iteration 3016.22 (Optional) Software Engineering Case Study: Identifying Class

Operations in the ATM System 3046.23 Wrap-Up 311

A gnyS @ffud VeCeDJS

3337.1 Introduction 3347.2 Arrays 3357.3 Declaring Arrays 3377.4 Examples Using Arrays 337

7.4.1 Declaring an Array and Using a Loop to Initialize theArray's Elements 337

7.4.2 Initializing an Array in a Declaration with an Initializer List 338

Page 5: SIXTH EDITION - CERNcds.cern.ch/record/1515663/files/0136152503_TOC.pdf · PEARSON E-How SIXTH EDITION 2ROGRAM Dehe' Deitel Assodaes, Inc. M. Jute Deitel & Associates, Inc. DEHTEL°

xii Contents

7.4.3 Specifying an Array's Size with a Constant Variable andSetting Array Elements with Calculations 340

7.4.4 Summing the Elements of an Array 342

7.4.5 Using Bar Charts to Display Array Data Graphically 343

7.4.6 Using the Elements of an Array as Counters 345

7.4.7 Using Arrays to Summarize Survey Results 346

7.4.8 Using Character Arrays to Store and Manipulate Strings 349

7.4.9 Static Local Arrays and Automatic Local Arrays 351

7.5 Passing Arrays to Functions 354

7.6 Case Study: Class GradeBook Using an Array to Store Grades 358

7.7 Searching Arrays with Linear Search 365

7.8 Sorting Arrays with Insertion Sort 366

7.9 Multidimensional Arrays 3697.10 Case Study: Class GradeBook Using a Two-Dimensional Array 3727.11 Introduction to C++ Standard Library Class Template vector 3797.12 (Optional) Software Engineering Case Study: Collaboration Among

Objects in the ATM System 3847.13 Wrap-Up 391

Poh2es Jod PoiiMe-f3@sed Shings 4088.1 Introduction 409

8.2 Pointer Variable Declarations and Initialization 410

8.3 Pointer Operators 411

8.4 Passing Arguments to Functions by Reference with Pointers 414

8.5 Using const with Pointers 418

8.6 Selection Sort Using Pass-by-Reference 425

8.7 s i zeof Operator 428

8.8 Pointer Expressions and Pointer Arithmetic 431

8.9 Relationship Between Pointers and Arrays 4348.10 Arrays of Pointers 4388.11 Case Study: Card Shuffling and Dealing Simulation 4398.12 Function Pointers 4458.13 Introduction to Pointer-Based String Processing 450

8.13.1 Fundamentals of Characters and Pointer-Based Strings 4518.13.2 String-Manipulation Functions of the String-Handling Library 453

8.14 Wrap-Up 461

Cll@SS2S°. A Beeperr 'Look, PEfe li 4879.1 Introduction 488

9.2 Time Class Case Study 489

9.3 Class Scope and Accessing Class Members 494

9.4 Separating Interface from Implementation 496

9.5 Access Functions and Utility Functions 498

9.6 Time Class Case Study: Constructors with Default Arguments 500

9.7 Destructors 506

Page 6: SIXTH EDITION - CERNcds.cern.ch/record/1515663/files/0136152503_TOC.pdf · PEARSON E-How SIXTH EDITION 2ROGRAM Dehe' Deitel Assodaes, Inc. M. Jute Deitel & Associates, Inc. DEHTEL°

Contents xiii

9.8 When Constructors and Destructors Are Called 5079.9 Ti me Class Case Study: A Subtle Trap-Returning a Reference to

a private Data Member 5109.10 Default Memberwise Assignment 5139.11 (Optional) Software Engineering Case Study: Starting to Program

the Classes of the ATM System 5159.12 Wrap-Up 523

Cll2SS2S: A 2e2p2fi- Leck, -0 me 2

53010.1 Introduction 53110.2 const (Constant) Objects and const Member Functions 53110.3 Composition: Objects as Members of Classes 54110.4 f ri end Functions and f ri end Classes 54810.5 Using the thi s Pointer 55210.6 Dynamic Memory Management with Operators new and del ete 55710.7 s t at i c Class Members 55910.8 Data Abstraction and Information Hiding 565

10.8.1 Example: Array Abstract Data Type 56610.8.2 Example: String Abstract Data Type 56710.8.3 Example: Queue Abstract Data Type 567

10.9 Container Classes and Iterators 56810.10 Proxy Classes 56810.11 Wrap-Up 572

0115xemhz OverrllomIng; 2llirng 2nd. AnmyCDIAects

57311.1 Introduction 57911.2 Fundamentals of Operator Overloading 58011.3 Restrictions an Operator Overloading 58111.4 Operator Functions as Class Members vs. Global Functions 58311.5 Overloading Stream Insertion and Stream Extraction Operators 58411.6 Overloading Unary Operators 58811.7 Overloading Binary Operators 58811.8 Case Study: Array Class 58911.9 Converting between Types 60111.10 Gase Study: St ri ng Class 60211.11 Overloading ++ and -- 61411.12 Case Study: A Date Class 61611.13 Standard Library Class st ri ng 62011.14 expl i ci t Constructors 62411.15 Wrap-Up 628

CDete=CDTficeAcid PTegrrunimkug g lnhß ge@nc© e4012.1 Introduction 641

Page 7: SIXTH EDITION - CERNcds.cern.ch/record/1515663/files/0136152503_TOC.pdf · PEARSON E-How SIXTH EDITION 2ROGRAM Dehe' Deitel Assodaes, Inc. M. Jute Deitel & Associates, Inc. DEHTEL°

xiv Contents

12.2 Base Classes and Derived Classes 642

12.3 protected Members 645

12.4 Relationship between Base Classes and Derived Classes 645

12.4.1 Creating and Using a Commi ssi onEmpl oyee Class 646

12.4.2 Creating a BasePl usCommi ssi onEmpl oyee Class Without UsingInheritance 651

12.4.3 Creating a Commi ssi onEmployee—BaseP1usCommi ssi onEmpl oyee

Inheritance Hierarchy 657

12.4.4 Commi ssi onEmpl oyee—BasePlusCommi ssi on Empl oyee InheritanceHierarchy Using protected Data 662

12.4.5 Commi ssi onEmpl oyee—BasePlusCommi ssi on Empl oyee InheritanceHierarchy Using private Data 669

12.5 Constructors and Destructors in Derived Classes 677

12.6 publ i c, protected and pri vate Inheritance 68512.7 Software Engineering with Inheritance 68512.8 Wrap-Up 687

Cb,he-Ordienged hezwernmihro PüllymogIlfiisin 69313.1 Introduction 69413.2 Polymorphism Examples 69613.3 Relationships Among Objects in an Inheritance Hierarchy 697

13.3.1 Invoking Base-Class Functions from Derived-Class Objects 69713.3.2 Aiming Derived-Class Pointers at Base-Class Objects 70513.3.3 Derived-Class Member-Function Calls via Base-Class Pointers 70613.3.4 Virtual Functions 70813.3.5 Summary of the Allowed Assignments Between Base-Class

and Derived-Class Objects and Pointers 71413.4 Type Fields and swi tch Statements 71513.5 Abstract Classes and Pure vi rtual Functions 71513.6 Case Study: Payroll System Using Polymorphism 717

13.6.1 Creating Abstract Base Class Employee 71913.6.2 Creating Concrete Derived Class Sal ari edEmpl oyee 72213.6.3 Creating Concrete Derived Class Hourl yEmployee 72413.6.4 Creating Concrete Derived Class Commi ssi onEmpl oyee 72713.6.5 Creating Indirect Concrete Derived Class

BasePlusCommi ssi onEmpl oyee 72913.6.6 Demonstrating Polymorphic Processing 731

13.7 (Optional) Polymorphism, Virtual Functions and Dynamic Binding"Under the Hood" 735

13.8 Case Study: Payroll System Using Polymorphism and Runtime TypeInformation with Downcasting, dynami c_cast, typei d and type_i nfo 739

13.9 Virtual Destructors 74213.10 (Optional) Software Engineering Case Study: Incorporating Inheritance

into the ATM System 74313.11 Wrap-Up 751

Page 8: SIXTH EDITION - CERNcds.cern.ch/record/1515663/files/0136152503_TOC.pdf · PEARSON E-How SIXTH EDITION 2ROGRAM Dehe' Deitel Assodaes, Inc. M. Jute Deitel & Associates, Inc. DEHTEL°

Contents xv

TUrilp1122S 75614.1 Introduction 75714.2 Function Templates 75814.3 Overloading Function Templates 76114.4 Class Templates 76114.5 Nontype Parameters and Default Types for Class Templates 76814.6 Notes on Templates and Inheritance 76914.7 Notes on Templates and Friends 76914.8 Notes on Templates and stati c Members 77014.9 Wrap-Up 771

Seremin ilnpefOuotpwA 77615.1 Introduction 77715.2 Streams 778

15.2.1 Classic Streams vs. Standard Streams 77915.2.2 iostream Library Header Files 77915.2.3 Stream Input/Output Classes and Objects 779

15.3 Stream Output 78215.3.1 Output of char * Variables 78215.3.2 Character Output Using Member Function put 782

15.4 Stream Input 78315.4.1 get and get1 i ne Member Functions 78415.4.2 i st ream Member Functions peek, putback and i gnore 78715.4.3 Type-Safe I/O 787

15.5 Unformatted I/O Using read, wri te and gcount 78715.6 Introduction to Stream Manipulators 788

15.6.1 Integral Stream Base: dec, oct, hex and setbase 78915.6.2 Floating-Point Precision (p reci si on, setpreci sion) 79015.6.3 Field Width (wi dth, s etw) 79115.6.4 User-Defined Output Stream Manipulators 793

15.7 Stream Format States and Stream Manipulators 79415.7.1 Trailing Zeros and Decimal Points (s howpoi nt) 79515.7.2 Justification (left, ri ght and i nte mal) 79615.7.3 Padding (fi 11, setfi 11) 79815.7.4 Integral Stream Base (dec, oct, hex, showbase) 79915.7.5 Floating-Point Numbers; Scientific and Fixed Notation

(sci enti fi c, fi xed) 80015.7.6 Uppercase/Lowercase Control (uppercase) 80015.7.7 Speciing Boolean Format (boolal pha) 80215.7.8 Setting and Resetting the Format State via Member

Function fl ags 80315.8 Stream Error States 80415.9 Tying an Output Stream to an Input Stream 80715.10 Wrap-Up 807

Page 9: SIXTH EDITION - CERNcds.cern.ch/record/1515663/files/0136152503_TOC.pdf · PEARSON E-How SIXTH EDITION 2ROGRAM Dehe' Deitel Assodaes, Inc. M. Jute Deitel & Associates, Inc. DEHTEL°

xvi Contents

lucepArionl Nmdilfing 8117818819819825826828829829831832832836839840841

Elle P)rocesg rng 84317.1 Introduction 84917.2 Data Hierarchy 84917.3 Files and Streams 85117.4 Creating a Sequential File 85217.5 Reading Data from a Sequential File 85617.6 Updating Sequential Files 86317.7 Random-Access Files 86317.8 Creating a Random-Access File 86417.9 Writing Data Randomly to a Random-Access File 86917.10 Reading from a Random-Access File Sequentially 87117.11 Case Study: A Transaction-Processing Program 87417.12 Overview of Object Serialization 88117.13 Wrap-Up 881

C11233 Stri ng unci Sefung Selle@ilin PT©cesgng 89318.1 Introduction 89418.2 stri ng Assignment and Concatenation 89518.3 Comparing st ri ngs 89718.4 Substrings 90018.5 Swapping st ri ngs 90118.6 stri ng Characteristics 90218.7 Finding Substrings and Characters in a st ri ng 90418.8 Replacing Characters in a st ri ng 90618.9 Inserting Characters into a st ri ng 90818.10 Conversion to C-Style Pointer-Based char * Strings 90918.11 Iterators 911

16.1 Introduction16.2 Exception-Handling Overview16.3 Example: Handling an Attempt to Divide by Zero16.4 When to Use Exception Handling16.5 Rethrowing an Exception16.6 Exception Specifications16.7 Processing Unexpected Exceptions16.8 Stack Unwinding16.9 Constructors, Destructors and Exception Handling16.10 Exceptions and Inheritance16.11 Processing new Failures16.12 Class auto_pt r and Dynamic Memory Allocation16.13 Standard Library Exception Hierarchy16.14 Other Error-Handling Techniques16.15 Wrap-Up

Page 10: SIXTH EDITION - CERNcds.cern.ch/record/1515663/files/0136152503_TOC.pdf · PEARSON E-How SIXTH EDITION 2ROGRAM Dehe' Deitel Assodaes, Inc. M. Jute Deitel & Associates, Inc. DEHTEL°

Contents xvii

18.12 String Stream Processing18.13 Wrap-Up

Sewake mnd Sorreng19.1 Introduction19.2 Searching Algorithms

19.2.1 Efficiency of Linear Search19.2.2 Binary Search

912915

922923923923925

19.3 Sorting Algorithms 93119.3.1 Efficiency of Selection Sort 93119.3.2 Efficiency of Insertion Sort 93119.3.3 Merge Sort (A Recursive Implementation) 932

19.4 Wrap-Up 939

Dmh Shrmemes 94520.1 Introduction 94620.2 Self-Referential Classes 94720.3 Dynamic Memory Allocation and Data Structures 94820.4 Linked Lists 94820.5 Stacks 96320.6 Queues 96820.7 Trees 97220.8 Wrap-Up 980

Ms, Ciumeem, C Strrings @i d. structs il ©0421.1 Introduction 100521.2 Structure Definitions 100521.3 Initializing Structures 100821.4 Using Structures with Functions 100821.5 typedef 100821.6 Example: High-Performance Card Shuffling and Dealing Simulation 100921.7 Bitwise Operators 101221.8 Bit Fields 102121.9 Character-Handling Library 102521.10 Pointer-Based S tring-Conversion Functions 103121.11 Search Functions of the Pointer-Based String-Handling Library 103621.12 Memory Functions of the Pointer-Based String-Handling Library 104121.13 Wrap-Up 1046

Shnorzge Iregullp112e lfibmi gy QSTIU 11057

22.1 Introduction to the Standard Template Library (STL) 105922.1.1 Introduction to Containers 106022.1.2 Introduction to Iterators 1064

Page 11: SIXTH EDITION - CERNcds.cern.ch/record/1515663/files/0136152503_TOC.pdf · PEARSON E-How SIXTH EDITION 2ROGRAM Dehe' Deitel Assodaes, Inc. M. Jute Deitel & Associates, Inc. DEHTEL°

xviii Contents

106910711072108010831085108610891090109210941094109610981099110011011104110611091112111411161118112011231125112811281130113411371138

22.1.3 Introduction to Algorithms22.2 Sequence Containers

22.2.1 vector Sequence Container22.2.2 li st Sequence Container22.2.3 deque Sequence Container

22.3 Associative Containers22.3.1 mul ti set Associative Container22.3.2 set Associative Container22.3.3 mult i map Associative Container22.3.4 map Associative Container

22.4 Container Adapters22.4.1 st ack Adapter22.4.2 queue Adapter22.4.3 pri ori ty_queue Adapter

22.5 Algorithms22.5.1 fi 11, fill_n, generate and generate_n

22.5.2 equal , mi smatch and lexi cog raphi cal _compare

22.5.3 remove, remove_i f, remove_copy and remove_copy_i f

22.5.4 repl ace, replace_i f, repl ace_copy and repl ace_copy_i f

22.5.5 Mathematical Algorithms22.5.6 Basic Searching and Sorting Algorithms22.5.7 swap, i ter_swap and swap_ranges

22.5.8 copy_backward, merge, uni que and reve rse

22.5.9 i np1 ace_merge, uni que_copy and reverse_copy

22.5.10 Set Operations22.5.11 lower_bound, upper_bound and equal_range

22.5.12 Heapsort22.5.13 min and max

22.5.14 STL Algorithms Not Covered in This Chapter22.6 Class bi tset

22.7 Function Objects22.8 Wrap-Up22.9 STL Web Resources

23.123.223.323.4

Gure Pa‚©grimlinnsiing vjien Ogre II 1143Introduction 1149Installing Ogre, OgreAL and OpenAL 1149Basics of Garne Programming 1149The Garne of Pong: Code Walkthrough 115223.4.1 Ogre Initialization 115323.4.2 Creating a Scene 116223.4.3 Adding to the Scene 116423.4.4 Animation and Timers 117523.4.5 User Input 117623.4.6 Collision Detection 1178

Page 12: SIXTH EDITION - CERNcds.cern.ch/record/1515663/files/0136152503_TOC.pdf · PEARSON E-How SIXTH EDITION 2ROGRAM Dehe' Deitel Assodaes, Inc. M. Jute Deitel & Associates, Inc. DEHTEL°

Contents xix

23.4.7 Sound 118423.4.8 Resources 118523.4.9 Pong Driver 1185

23.5 Wrap-Up 1111887623.6 Ogre Web Resources

Boes Lfikallciies, TezhnkmIlRepeEe 11

@nd C++Om

fi 11 97

24.1 Introduction 119824.2 Deitel Online C++ and Related Resource Centers 119824.3 Boost Libraries 119924.4 Adding a New Library to Boost 119924.5 Installing the Boost Libraries 120024.6 Boost Libraries in Technical Report 1 (TR1) 120024.7 Regular Expressions with the Boost. Regex Li brary 1203

24.7.1 Regular Expression Example 120424.7.2 Validating User Input with Regular Expressions 120624.7.3 Replacing and Splitting Strings 1209

24.8 Smart Pointers with Boost .Smart_ptr 121224.8.1 Reference Counted shared_ptr 121224.8.2 weak_pt r: shared_ptr Observer 1217

24.9 Technical Report 1 122324.10 C++Ox 122424.11 Core Language Changes 122424.12 Wrap-Up 1229

hefi‚ Topfics

25.1 Introduction25.2 const_cast Operator25.3 namespaces

25.4 Operator Keywords25.5 mutable Class Members25.6 Pointers to Class Members (.* and ->*)25.7 Multiple Inheritance25.8 Multiple Inheritance and vi rtual Base Classes25.9 Wrap-Up

11233

123912391241124512471249125112561260

A.1

CDperr2orr PTecedence und

Operator Precedence

ASCH Chumecerr Sets

AssezfiAve Ch@A fi 2661266

X269

1Fmnid@ffiffleffhil Typ3s 11270

Page 13: SIXTH EDITION - CERNcds.cern.ch/record/1515663/files/0136152503_TOC.pdf · PEARSON E-How SIXTH EDITION 2ROGRAM Dehe' Deitel Assodaes, Inc. M. Jute Deitel & Associates, Inc. DEHTEL°

xx Constants

._Kullialfoerc Systegno [1272D.1 Introduction 1273

D.2 Abbreviating Binary Numbers as Octal and Hexadecimal Numbers 1276

D.3 Converting Octal and Hexadecimal Numbers to Binary Numbers 1277

D.4 Converting from Binary, Octal or Hexadecimal to Decimal 1277

D.5 Converting from Decimal to Binary, Octal or Hexadecimal 1278

D.6 Negative Binary Numbers: Two's Complement Notation 1280

C Leg@cy Code To[AcsH 21 23.856E.1 Introduction

E.2 Redirecting Input/Output on UNIX/Linux/Mac OS X andWindows Systems 1286

E.3 Variable-Length Argument Lists 1287E.4 Using Command-Line Arguments 1290E.5 Notes on Compiling Multiple-Source-File Programs 1291E.6 Program Termination with exi t and atexi t 1293E.7 Type Qualifier vol ati le 1295E.8 Suffixes for Integer and Floating-Point Constants 1295E.9 Signal Handling 1295E.10 Dynamic Memory Allocation with cal oc and real 1 oc 1298E.11 Unconditional Branch: goto 1299E.12 Unions 1300E.13 Linkage Specifications 1303E.14 Wrap-Up 1304

?rfeLDJOCeSSOff 113 g 11F.1 Introduction 1312F.2 The #i ncl ude Preprocessor Directive 1312F.3 The #defi ne Preprocessor Directive: Symbolic Constants

113313

F.4 The #defi ne Preprocessor Directive: Macros 1313F.5 Conditional Compilation 1315F.6 The #er ror and #pragma Preprocessor Directives 1316F.7 Operators # and ## 1317F.8 Predefined Symbolic Constants 1317F.9 Assertions 1318F.10 Wrap-Up 1318

ATM CalS2 Study Code 11 323G.1 ATM Case Study Implementation 1323G.2 Class ATM 1324G.3 Class Screen 1331G.4 Class Keypad

G.5 Class CashDi spense r11333323

Page 14: SIXTH EDITION - CERNcds.cern.ch/record/1515663/files/0136152503_TOC.pdf · PEARSON E-How SIXTH EDITION 2ROGRAM Dehe' Deitel Assodaes, Inc. M. Jute Deitel & Associates, Inc. DEHTEL°

Contents xxi

G.6 Class Deposi tS1 ot 1335G.7 Class Account 1336G.8 Class BankDatabase 1338G.9 Class Transacti on 1342G.10 Class Bal anceInqui ry 1344G.11 Class Wi thd rawal 1346G.12 Class Deposi t 1351G.13 Test Program ATMCaseStudy. . cpp 1354G.14 Wrap-Up 1354

UWE, 120 Aadriemmil liDh,grmrdn Types 11355H.1 Introduction 1355H.2 Additional Diagram Types 1355

Usfing Vrisemll Debugger 11 357I.1 Introduction 13581.2 Breakpoints and the Continue Command 13581.3 Locals and Watch Windows 13631.4 Controlling ExecutionUsing die Step Into, Step Over, Step Out and

Continue Commands 13661.5 Autos Window 13691.6 Wrap-Up 1370

C{ 11 idne GNU C++ Debugger(' 11373

J.1 Introduction 1374

J.2 Breakpoints and die run, stop, conti nue and pri nt Commands 1374

J.3 pri nt and set Commands13J.4 Controlling Execution Using the step, fi ni sh and next Commands 13833

J.5 wat ch Command 1385

J.6 Wrap-Up 1387

BfiblIfiegrimphy

lindem

11390

11396