Tải bản đầy đủ (.pdf) (3,186 trang)

Prentice hall c plus plus how to program 5th edition jan 2005 ISBN 0131857576

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (16.72 MB, 3,186 trang )



C++HowtoProgram,FifthEdition
ByH.M.Deitel-Deitel&Associates,Inc.,
P.J.Deitel-Deitel&Associates,Inc.
Publisher :PrenticeHall
PubDate :January05,2005
PrintISBN-10 :0-13-185757-6
eTextISBN-10 :0-13-186103-4
PrintISBN-13 :978-0-13-185757-5

Tableof eTextISBN-13 :978-0-13-186103-9

Pages :1536
Contents
• Index

Best-sellingC++textsignificantlyrevisedtoincludenewearly
objectscoverageandnewstreamlinedcasestudies.






C++HowtoProgram,FifthEdition
ByH.M.Deitel-Deitel&Associates,Inc.,
P.J.Deitel-Deitel&Associates,Inc.
Publisher :PrenticeHall
PubDate :January05,2005
PrintISBN-10 :0-13-185757-6



eTextISBN-10 :0-13-186103-4
Tableof

Contents PrintISBN-13 :978-0-13-185757-5
eTextISBN-13 :978-0-13-186103-9
• Index
Pages :1536




































Copyright
Deitel®Books,CyberClassrooms,CompleteTrainingCoursesandWebBasedTrainingCoursespublishedbyPrenticeHall
Preface
FeaturesofC++HowtoProgram,5/e
TeachingApproach
TouroftheBook
Object-OrientedDesignofanATMwiththeUML:ATouroftheOptional
SoftwareEngineeringCaseStudy
SoftwareBundledwithC++HowtoProgram,5/e
TeachingResourcesforC++HowtoProgram,5/e
C++MultimediaCyberClassroom,5/e,Online
C++intheLab
CourseCompassSM,WebCT™andBlackboard™
PearsonChoices
TheDeitel®BuzzOnlineFreeE-mailNewsletter
Acknowledgments
AbouttheAuthors

AboutDeitel&Associates,Inc.
BeforeYouBegin
ResourcesontheCDThatAccompaniesC++HowtoProgram,Fifth
Edition

iv
ii
xxiii
xxiii
xxvii
xxxi
xliv
xlvi
xlix
xlix
xlix
li
lii
liii
liii
lvi
lvii
lix
lix














































































CopyingandOrganizingFiles
CopyingtheBookExamplesfromtheCD
ChangingtheRead-OnlyPropertyofFiles
Chapter1.IntroductiontoComputers,theInternetandWorldWideWeb
Section1.1.Introduction
Section1.2.WhatIsaComputer?
Section1.3.ComputerOrganization
Section1.4.EarlyOperatingSystems
Section1.5.Personal,DistributedandClient/ServerComputing
Section1.6.TheInternetandtheWorldWideWeb
Section1.7.MachineLanguages,AssemblyLanguagesandHigh-Level
Languages
Section1.8.HistoryofCandC++
Section1.9.C++StandardLibrary
Section1.10.HistoryofJava
Section1.11.FORTRAN,COBOL,PascalandAda
Section1.12.Basic,VisualBasic,VisualC++,C#and.NET
Section1.13.KeySoftwareTrend:ObjectTechnology
Section1.14.TypicalC++DevelopmentEnvironment
Section1.15.NotesAboutC++andC++HowtoProgram,5/e
Section1.16.Test-DrivingaC++Application

Section1.17.SoftwareEngineeringCaseStudy:IntroductiontoObject
TechnologyandtheUML(Required)
Section1.18.Wrap-Up
Section1.19.WebResources
Summary
Terminology
Self-ReviewExercises
AnswerstoSelf-ReviewExercises
Exercises
Chapter2.IntroductiontoC++Programming
Section2.1.Introduction
Section2.2.FirstPrograminC++:PrintingaLineofText
Section2.3.ModifyingOurFirstC++Program
Section2.4.AnotherC++Program:AddingIntegers
Section2.5.MemoryConcepts
Section2.6.Arithmetic
Section2.7.DecisionMaking:EqualityandRelationalOperators
Section2.8.(Optional)SoftwareEngineeringCaseStudy:Examiningthe

lix
lx
lx
1
2
3
4
5
5
6
6

8
8
9
10
11
11
12
15
16
22
27
27
29
31
33
34
34
36
37
37
41
42
46
48
51










































ATMRequirementsDocument




































Section2.9.Wrap-Up
Summary
Terminology
Self-ReviewExercises
AnswerstoSelf-ReviewExercises
Exercises
Chapter3.IntroductiontoClassesandObjects
Section3.1.Introduction
Section3.2.Classes,Objects,MemberFunctionsandDataMembers
Section3.3.OverviewoftheChapterExamples
Section3.4.DefiningaClasswithaMemberFunction
Section3.5.DefiningaMemberFunctionwithaParameter
Section3.6.DataMembers,setFunctionsandgetFunctions
Section3.7.InitializingObjectswithConstructors
Section3.8.PlacingaClassinaSeparateFileforReusability
Section3.9.SeparatingInterfacefromImplementation
Section3.10.ValidatingDatawithsetFunctions
Section3.11.(Optional)SoftwareEngineeringCaseStudy:Identifyingthe
ClassesintheATMRequirementsDocument

Section3.12.Wrap-Up
Summary
Terminology
Self-ReviewExercises
AnswerstoSelf-ReviewExercises
Exercises
Chapter4.ControlStatements:Part1
Section4.1.Introduction
Section4.2.Algorithms
Section4.3.Pseudocode
Section4.4.ControlStructures
Section4.5.ifSelectionStatement
Section4.6.if...elseDouble-SelectionStatement
Section4.7.whileRepetitionStatement
Section4.8.FormulatingAlgorithms:Counter-ControlledRepetition
Section4.9.FormulatingAlgorithms:Sentinel-ControlledRepetition
Section4.10.FormulatingAlgorithms:NestedControlStatements
Section4.11.AssignmentOperators

56
65
65
67
68
69
70
74
75
75
77

77
81
84
91
95
99
105
110
118
118
121
121
122
122
124
125
125
126
127
131
132
137
139
145
156
161





Section4.12.IncrementandDecrementOperators

161



Section4.13.(Optional)SoftwareEngineeringCaseStudy:Identifying
ClassAttributesintheATMSystem

165

Section4.14.Wrap-Up
Summary
Terminology
Self-ReviewExercises
AnswerstoSelf-ReviewExercises
Exercises
Chapter5.ControlStatements:Part2
Section5.1.Introduction
Section5.2.EssentialsofCounter-ControlledRepetition
Section5.3.forRepetitionStatement
Section5.4.ExamplesUsingtheforStatement
Section5.5.do...whileRepetitionStatement
Section5.6.switchMultiple-SelectionStatement
Section5.7.breakandcontinueStatements
Section5.8.LogicalOperators
Section5.9.ConfusingEquality(==)andAssignment(=)Operators
Section5.10.StructuredProgrammingSummary
Section5.11.(Optional)SoftwareEngineeringCaseStudy:Identifying
Objects'StatesandActivitiesintheATMSystem

Section5.12.Wrap-Up
Summary
Terminology
Self-ReviewExercises
AnswerstoSelf-ReviewExercises
Exercises
Chapter6.FunctionsandanIntroductiontoRecursion
Section6.1.Introduction
Section6.2.ProgramComponentsinC++
Section6.3.MathLibraryFunctions
Section6.4.FunctionDefinitionswithMultipleParameters
Section6.5.FunctionPrototypesandArgumentCoercion
Section6.6.C++StandardLibraryHeaderFiles
Section6.7.CaseStudy:RandomNumberGeneration
Section6.8.CaseStudy:GameofChanceandIntroducingenum
Section6.9.StorageClasses
Section6.10.ScopeRules

169
170
172
173
174
177
185
186
186
188
193
197

199
209
211
216
217









































































222
226
228
230
230
231
233
238
239
240
241
243
248
250

252
258
262
265




Section6.11.FunctionCallStackandActivationRecords

268




Section6.12.FunctionswithEmptyParameterLists
Section6.13.InlineFunctions

272
273


































































Section6.14.ReferencesandReferenceParameters
Section6.15.DefaultArguments
Section6.16.UnaryScopeResolutionOperator
Section6.17.FunctionOverloading
Section6.18.FunctionTemplates
Section6.19.Recursion

Section6.20.ExampleUsingRecursion:FibonacciSeries
Section6.21.Recursionvs.Iteration
Section6.22.(Optional)SoftwareEngineeringCaseStudy:Identifying
ClassOperationsintheATMSystem
Section6.23.Wrap-Up
Summary
Terminology
Self-ReviewExercises
AnswerstoSelf-ReviewExercises
Exercises
Chapter7.ArraysandVectors
Section7.1.Introduction
Section7.2.Arrays
Section7.3.DeclaringArrays
Section7.4.ExamplesUsingArrays
Section7.5.PassingArraystoFunctions
Section7.6.CaseStudy:ClassGradeBookUsinganArraytoStore
Grades
Section7.7.SearchingArrayswithLinearSearch
Section7.8.SortingArrayswithInsertionSort
Section7.9.MultidimensionalArrays
Section7.10.CaseStudy:ClassGradeBookUsingaTwo-Dimensional
Array
Section7.11.IntroductiontoC++StandardLibraryClassTemplatevector
Section7.12.(Optional)SoftwareEngineeringCaseStudy:Collaboration
AmongObjectsintheATMSystem
Section7.13.Wrap-Up
Summary
Terminology
Self-ReviewExercises


275
280
282
283
286
288
292
295
298
305
306
309
311
313
316
326
327
328
329
330
346
351
358
359
362
365
372
377
385

385
387
388




AnswerstoSelf-ReviewExercises

389




Exercises
RecursionExercises

390
400










































































vectorExercises
Chapter8.PointersandPointer-BasedStrings
Section8.1.Introduction
Section8.2.PointerVariableDeclarationsandInitialization
Section8.3.PointerOperators
Section8.4.PassingArgumentstoFunctionsbyReferencewithPointers
Section8.5.UsingconstwithPointers
Section8.6.SelectionSortUsingPass-by-Reference
Section8.7.sizeofOperators
Section8.8.PointerExpressionsandPointerArithmetic
Section8.9.RelationshipBetweenPointersandArrays
Section8.10.ArraysofPointers
Section8.11.CaseStudy:CardShufflingandDealingSimulation
Section8.12.FunctionPointers
Section8.13.IntroductiontoPointer-BasedStringProcessing
Section8.14.Wrap-Up
Summary
Terminology
Self-ReviewExercises
AnswerstoSelf-ReviewExercises
Exercises
SpecialSection:BuildingYourOwnComputer
MorePointerExercises
String-ManipulationExercises
SpecialSection:AdvancedString-ManipulationExercises
AChallengingString-ManipulationProject
Chapter9.Classes:ADeeperLook,Part1
Section9.1.Introduction
Section9.2.TimeClassCaseStudy
Section9.3.ClassScopeandAccessingClassMembers

Section9.4.SeparatingInterfacefromImplementation
Section9.5.AccessFunctionsandUtilityFunctions
Section9.6.TimeClassCaseStudy:ConstructorswithDefaultArguments
Section9.7.Destructors
Section9.8.WhenConstructorsandDestructorsAreCalled

400
401
402
403
404
407
411
418
421
424
427
431
432
438
443
454
455
456
457
459
461
464
469
474

475
479
480
481
482
487
489
491
493
499
500




Section9.9.TimeClassCaseStudy:ASubtleTrapReturningaReference 503
toaprivateDataMember



Section9.10.DefaultMemberwiseAssignment



































































Section9.11.SoftwareReusability
Section9.12.(Optional)SoftwareEngineeringCaseStudy:Startingto
ProgramtheClassesoftheATMSystem
Section9.13.Wrap-Up

Summary
Terminology
Self-ReviewExercises
AnswerstoSelf-ReviewExercises
Exercises
Chapter10.Classes:ADeeperLook,Part2
Section10.1.Introduction
Section10.2.const(Constant)ObjectsandconstMemberFunctions
Section10.3.Composition:ObjectsasMembersofClasses
Section10.4.friendFunctionsandfriendClasses
Section10.5.UsingthethisPointer
Section10.6.DynamicMemoryManagementwithOperatorsnewand
delete
Section10.7.staticClassMembers
Section10.8.DataAbstractionandInformationHiding
Section10.9.ContainerClassesandIterators
Section10.10.ProxyClasses
Section10.11.Wrap-Up
Summary
Terminology
Self-ReviewExercises
AnswerstoSelf-ReviewExercises
Exercises
Chapter11.OperatorOverloading;StringandArrayObjects
Section11.1.Introduction
Section11.2.FundamentalsofOperatorOverloading
Section11.3.RestrictionsonOperatorOverloading
Section11.4.OperatorFunctionsasClassMembersvs.GlobalFunctions
Section11.5.OverloadingStreamInsertionandStreamExtraction
Operators

Section11.6.OverloadingUnaryOperators
Section11.7.OverloadingBinaryOperators

506
508
509
516
517
519
519
520
520
523
524
524
534
541
545
550
552
558
561
562
565
566
567
568
569
569
571

572
573
574
576
577
581
581












































































Section11.8.CaseStudy:ArrayClass
Section11.9.ConvertingbetweenTypes
Section11.10.CaseStudy:StringClass
Section11.11.Overloading++and-Section11.12.CaseStudy:ADateClass
Section11.13.StandardLibraryClassstring
Section11.14.explicitConstructors
Section11.15.Wrap-Up
Summary
Terminology

Self-ReviewExercises
AnswerstoSelf-ReviewExercises
Exercises
Chapter12.Object-OrientedProgramming:Inheritance
Section12.1.Introduction
Section12.2.BaseClassesandDerivedClasses
Section12.3.protectedMembers
Section12.4.RelationshipbetweenBaseClassesandDerivedClasses
Section12.5.ConstructorsandDestructorsinDerivedClasses
Section12.6.public,protectedandprivateInheritance
Section12.7.SoftwareEngineeringwithInheritance
Section12.8.Wrap-Up
Summary
Terminology
Self-ReviewExercises
AnswerstoSelf-ReviewExercises
Exercises
Chapter13.Object-OrientedProgramming:Polymorphism
Section13.1.Introduction
Section13.2.PolymorphismExamples
Section13.3.RelationshipsAmongObjectsinanInheritanceHierarchy
Section13.4.TypeFieldsandswitchStatements
Section13.5.AbstractClassesandPurevirtualFunctions
Section13.6.CaseStudy:PayrollSystemUsingPolymorphism
Section13.7.(Optional)Polymorphism,VirtualFunctionsandDynamic
Binding"UndertheHood"
Section13.8.CaseStudy:PayrollSystemUsingPolymorphismandRunTimeTypeInformationwithDowncasting,dynamic_cast,typeidand
type_info

582

594
595
607
609
613
617
621
621
624
624
625
625
633
634
635
638
638
670
678
678
680
681
682
682
683
683
686
687
689
690

707
708
710
728
732















































































Section13.9.VirtualDestructors
Section13.10.(Optional)SoftwareEngineeringCaseStudy:Incorporating
InheritanceintotheATMSystem
Section13.11.Wrap-Up
Summary
Terminology
Self-ReviewExercises
AnswerstoSelf-ReviewExercises

Exercises
Chapter14.Templates
Section14.1.Introduction
Section14.2.FunctionTemplates
Section14.3.OverloadingFunctionTemplates
Section14.4.ClassTemplates
Section14.5.NontypeParametersandDefaultTypesforClassTemplates
Section14.6.NotesonTemplatesandInheritance
Section14.7.NotesonTemplatesandFriends
Section14.8.NotesonTemplatesandstaticMembers
Section14.9.Wrap-Up
Summary
Terminology
Self-ReviewExercises
AnswerstoSelf-ReviewExercises
Exercises
Chapter15.StreamInput/Output
Section15.1.Introduction
Section15.2.Streams
Section15.3.StreamOutput
Section15.4.StreamInput
Section15.5.UnformattedI/Ousingread,writeandgcount
Section15.6.IntroductiontoStreamManipulators
Section15.7.StreamFormatStatesandStreamManipulators
Section15.8.StreamErrorStates
Section15.9.TyinganOutputStreamtoanInputStream
Section15.10.Wrap-Up
Summary
Terminology
Self-ReviewExercises

AnswerstoSelf-ReviewExercises

735
736
744
744
746
746
747
747
749
750
751
754
754
761
762
762
763
764
764
765
766
766
766
769
770
771
775
776

780
781
787
797
800
800
800
803
804
806




Exercises

808


Chapter16.ExceptionHandling

Section16.1.Introduction

810
811








































812
812
819
820
821
822
823
824
825
825
829
832
834
834
835
837
838
838
839
841
842
842
844
845
849
856
856

857
862
864
867
874
874
874
876
876






































Section16.2.Exception-HandlingOverview
Section16.3.Example:HandlinganAttempttoDividebyZero
Section16.4.WhentoUseExceptionHandling
Section16.5.RethrowinganException
Section16.6.ExceptionSpecifications
Section16.7.ProcessingUnexpectedExceptions
Section16.8.StackUnwinding
Section16.9.Constructors,DestructorsandExceptionHandling
Section16.10.ExceptionsandInheritance
Section16.11.ProcessingnewFailures
Section16.12.Classauto_ptrandDynamicMemoryAllocation
Section16.13.StandardLibraryExceptionHierarchy
Section16.14.OtherError-HandlingTechniques
Section16.15.Wrap-Up

Summary
Terminology
Self-ReviewExercises
AnswerstoSelf-ReviewExercises
Exercises
Chapter17.FileProcessing
Section17.1.Introduction
Section17.2.TheDataHierarchy
Section17.3.FilesandStreams
Section17.4.CreatingaSequentialFile
Section17.5.ReadingDatafromaSequentialFile
Section17.6.UpdatingSequentialFiles
Section17.7.Random-AccessFiles
Section17.8.CreatingaRandom-AccessFile
Section17.9.WritingDataRandomlytoaRandom-AccessFile
Section17.10.ReadingfromaRandom-AccessFileSequentially
Section17.11.CaseStudy:ATransaction-ProcessingProgram
Section17.12.Input/OutputofObjects
Section17.13.Wrap-Up
Summary
Terminology
Self-ReviewExercises



AnswerstoSelf-ReviewExercises

Exercises

Chapter18.ClassstringandStringStreamProcessing


877
878
883






































884
885
887
890
891
892
894
896
898
899
901
902
905
906
907
907
908
908
911

912
913
914
915
916
917
917
918
920
928
928
938
939
943
949
954





































Section18.1.Introduction
Section18.2.stringAssignmentandConcatenation
Section18.3.Comparingstrings
Section18.4.Substrings
Section18.5.Swappingstrings
Section18.6.stringCharacteristics
Section18.7.FindingStringsandCharactersinastring
Section18.8.ReplacingCharactersinastring

Section18.9.InsertingCharactersintoastring
Section18.10.ConversiontoC-StylePointer-Basedchar*Strings
Section18.11.Iterators
Section18.12.StringStreamProcessing
Section18.13.Wrap-Up
Summary
Terminology
Self-ReviewExercises
AnswerstoSelf-ReviewExercises
Exercises
Chapter19.WebProgramming
Section19.1.Introduction
Section19.2.HTTPRequestTypes
Section19.3.MultitierArchitecture
Section19.4.AccessingWebServers
Section19.5.ApacheHTTPServer
Section19.6.RequestingXHTMLDocuments
Section19.7.IntroductiontoCGI
Section19.8.SimpleHTTPTransactions
Section19.9.SimpleCGIScripts
Section19.10.SendingInputtoaCGIScript
Section19.11.UsingXHTMLFormstoSendInput
Section19.12.OtherHeaders
Section19.13.CaseStudy:AnInteractiveWebPage
Section19.14.Cookies
Section19.15.Server-SideFiles
Section19.16.CaseStudy:ShoppingCart





Section19.17.Wrap-Up

969





Section19.18.InternetandWebResources
Summary
Terminology

969
970
972






































































Self-ReviewExercises
AnswerstoSelf-ReviewExercises
Exercises
Chapter20.SearchingandSorting
Section20.1.Introduction
Section20.2.SearchingAlgorithms

Section20.3.SortingAlgorithms
Section20.4.Wrap-Up
Summary
Terminology
Self-ReviewExercises
AnswerstoSelf-ReviewExercises
Exercises
Chapter21.DataStructures
Section21.1.Introduction
Section21.2.Self-ReferentialClasses
Section21.3.DynamicMemoryAllocationandDataStructures
Section21.4.LinkedLists
Section21.5.Stacks
Section21.6.Queues
Section21.7.Trees
Section21.8.Wrap-Up
Summary
Terminology
Self-ReviewExercises
AnswerstoSelf-ReviewExercises
Exercises
SpecialSection:BuildingYourOwnCompiler
Chapter22.Bits,Characters,C-Stringsandstructs
Section22.1.Introduction
Section22.2.StructureDefinitions
Section22.3.InitializingStructures
Section22.4.UsingStructureswithFunctions
Section22.5.typedef

973

973
974
975
976
976
982
992
992
994
994
995
995
998
999
1000
1001
1001
1016
1021
1025
1033
1034
1035
1036
1037
1038
1043
1057
1058
1058

1061
1061
1061




Section22.6.Example:High-PerformanceCardShufflingandDealing
Simulation

1062





Section22.7.BitwiseOperators
Section22.8.BitFields
Section22.9.Character-HandlingLibrary

1065
1074
1078
































































Section22.10.Pointer-BasedString-ConversionFunctions
Section22.11.SearchFunctionsofthePointer-BasedString-Handling
Library
Section22.12.MemoryFunctionsofthePointer-BasedString-Handling
Library

Section22.13.Wrap-Up
Summary
Terminology
Self-ReviewExercises
AnswerstoSelf-ReviewExercises
Exercises
Chapter23.StandardTemplateLibrary(STL)
Section23.1.IntroductiontotheStandardTemplateLibrary(STL)
Section23.2.SequenceContainers
Section23.3.AssociativeContainers
Section23.4.ContainerAdapters
Section23.5.Algorithms
Section23.6.Classbitset
Section23.7.FunctionObjects
Section23.8.Wrap-Up
Section23.9.STLInternetandWebResources
Summary
Terminology
Self-ReviewExercises
AnswerstoSelf-ReviewExercises
Exercises
RecommendedReading
Chapter24.OtherTopics
Section24.1.Introduction
Section24.2.const_castOperator
Section24.3.namespaces
Section24.4.OperatorKeywords
Section24.5.mutableClassMembers

1084

1089
1094
1099
1099
1101
1102
1103
1104
1110
1112
1124
1138
1147
1152
1183
1187
1190
1191
1192
1196
1197
1198
1198
1199
1200
1201
1201
1203
1207
1209





Section24.6.PointerstoClassMembers(.*and->*)

1211















Section24.7.MultipleInheritance
Section24.8.MultipleInheritanceandvirtualBaseClasses
Section24.9.Wrap-Up
Section24.10.ClosingRemarks
Summary
Terminology

1213

1218
1222
1223
1223
1225





























































Self-ReviewExercises
AnswerstoSelf-ReviewExercises
Exercises
AppendixA.OperatorPrecedenceandAssociativityChart
SectionA.1.OperatorPrecedence
AppendixB.ASCIICharacterSet
AppendixC.FundamentalTypes
AppendixD.NumberSystems
SectionD.1.Introduction
SectionD.2.AbbreviatingBinaryNumbersasOctalandHexadecimal
Numbers
SectionD.3.ConvertingOctalandHexadecimalNumberstoBinary
Numbers
SectionD.4.ConvertingfromBinary,OctalorHexadecimaltoDecimal
SectionD.5.ConvertingfromDecimaltoBinary,OctalorHexadecimal
SectionD.6.NegativeBinaryNumbers:Two'sComplementNotation
Summary
Terminology
Self-ReviewExercises
AnswerstoSelf-ReviewExercises
Exercises
AppendixE.CLegacyCodeTopics
SectionE.1.Introduction
SectionE.2.RedirectingInput/OutputonUNIX/LINUX/MacOSXand
WindowsSystems
SectionE.3.Variable-LengthArgumentLists

SectionE.4.UsingCommand-LineArguments
SectionE.5.NotesonCompilingMultiple-Source-FilePrograms
SectionE.6.ProgramTerminationwithexitandatexit
SectionE.7.ThevolatileTypeQualifier
SectionE.8.SuffixesforIntegerandFloating-PointConstants
SectionE.9.SignalHandling

1225
1226
1226
1228
1228
1231
1232
1234
1235
1238
1239
1239
1240
1242
1243
1243
1244
1245
1246
1247
1248
1248
1249

1252
1253
1255
1257
1257
1257




SectionE.10.DynamicMemoryAllocationwithcallocandrealloc

1260



SectionE.11.TheUnconditionalBranch:goto

1261












































































SectionE.12.Unions
SectionE.13.LinkageSpecifications
SectionE.14.Wrap-Up
Summary
Terminology
Self-ReviewExercises
AnswerstoSelf-ReviewExercises
Exercises
AppendixF.Preprocessor
SectionF.1.Introduction
SectionF.2.The#includePreprocessorDirective
SectionF.3.The#definePreprocessorDirective:SymbolicConstants
SectionF.4.The#definePreprocessorDirective:Macros
SectionF.5.ConditionalCompilation
SectionF.6.The#errorand#pragmaPreprocessorDirectives
SectionF.7.The#and##Operators
SectionF.8.PredefinedSymbolicConstants
SectionF.9.Assertions
SectionF.10.Wrap-Up
Summary
Terminology
Self-ReviewExercises
AnswerstoSelf-ReviewExercises
Exercises
AppendixG.ATMCaseStudyCode
SectionG.1.ATMCaseStudyImplementation
SectionG.2.ClassATM
SectionG.3.ClassScreen

SectionG.4.ClassKeypad
SectionG.5.ClassCashDispenser
SectionG.6.ClassDepositSlot
SectionG.7.ClassAccount
SectionG.8.ClassBankDatabase
SectionG.9.ClassTransaction
SectionG.10.ClassBalanceInquiry
SectionG.11.ClassWithdrawal

1262
1265
1266
1267
1269
1269
1270
1270
1272
1273
1273
1274
1275
1277
1278
1278
1279
1279
1280
1280
1281

1281
1282
1283
1285
1285
1286
1293
1294
1295
1297
1298
1300
1304
1306
1308




SectionG.12.ClassDeposit

1313




SectionG.13.TestProgramATMCaseStudy.cpp
SectionG.14.Wrap-Up

1316

1317







































































AppendixH.UML2:AdditionalDiagramTypes
SectionH.1.Introduction
SectionH.2.AdditionalDiagramTypes
AppendixI.C++InternetandWebResources
SectionI.1.Resources
SectionI.2.Tutorials
SectionI.3.FAQs
SectionI.4.VisualC++
SectionI.5.Newsgroups
SectionI.6.CompilersandDevelopmentTools
SectionI.7.StandardTemplateLibrary
AppendixJ.IntroductiontoXHTML
SectionJ.1.Introduction
SectionJ.2.EditingXHTML
SectionJ.3.FirstXHTMLExample
SectionJ.4.Headers
SectionJ.5.Linking
SectionJ.6.Images
SectionJ.7.SpecialCharactersandMoreLineBreaks
SectionJ.8.UnorderedLists

SectionJ.9.NestedandOrderedLists
SectionJ.10.BasicXHTMLTables
SectionJ.11.IntermediateXHTMLTablesandFormatting
SectionJ.12.BasicXHTMLForms
SectionJ.13.MoreComplexXHTMLForms
SectionJ.14.InternetandWorldWideWebResources
Summary
Terminology
AppendixK.XHTMLSpecialCharacters
AppendixL.UsingtheVisualStudio.NETDebugger
SectionL.1.Introduction
SectionL.2.BreakpointsandtheContinueCommand
SectionL.3.TheLocalsandWatchWindows
SectionL.4.ControllingExecutionUsingtheStepInto,StepOver,Step
OutandContinueCommands
SectionL.5.TheAutosWindow

1318
1318
1318
1320
1320
1322
1322
1322
1323
1323
1324
1325
1326

1326
1327
1330
1331
1333
1338
1340
1340
1341
1346
1349
1352
1359
1359
1361
1363
1364
1365
1365
1371
1374
1377




SectionL.6.Wrap-Up

1378





Summary
Terminology

1379
1380







































PrenticeHallLicenseAgreementandLimitedWarranty
LicenseAgreementandLimitedWarranty




Self-ReviewExercises
AnswerstoSelf-ReviewExercises
AppendixM.UsingtheGNUC++Debugger
SectionM.1.Introduction
SectionM.2.Breakpointsandtherun,stop,continueandprintCommands
SectionM.3.TheprintandsetCommands
SectionM.4.ControllingExecutionUsingthestep,finishandnext
Commands

SectionM.5.ThewatchCommand
SectionM.6.Wrap-Up
Summary
Terminology
Self-ReviewExercises
AnswerstoSelf-ReviewExercises
Bibliography
EndUserLicenseAgreements



UsingtheCD-ROM



ContentsoftheCD-ROM



SoftwareandHardwareSystemRequirements
Index

1380
1380
1381
1382
1382
1389
1391
1393

1396
1397
1398
1398
1398
1399
EULA1
EULA1
EULA3
EULA3
EULA3
EULA3


[Pageiv]


Copyright
LibraryofCongressCataloging-in-PublicationData
Onfile
VicePresidentandEditorialDirector,ECS:MarciaJ.
Horton
SeniorAcquisitionsEditor:KateHargett
AssociateEditor:JenniferCappello
AssistantEditor:SarahParker
EditorialAssistant:MichaelGiacobbe
ExecutiveManagingEditor:VinceO'Brien
ManagingEditor:TomManshreck
ProductionEditor:JohnF.Lovell
ProductionEditor,Media:BobEngelhardt

ProductionAssistant:AshaRohra
DirectorofCreativeServices:PaulBelfanti
A/VProductionEditor:XiaohongZhu
ArtStudio:Artworks,York,PA


ArtDirector:GeoffreyCassar
CoverDesign:AbbeyS.Deitel,HarveyM.Deitel,
FrancescoSantalucia,GeoffreyCassar
InteriorDesign:HarveyM.Deitel,GeoffreyCassar
AssistantManufacturingManager:MichaelBell
ManufacturingBuyer:LisaMcDowell
MarketingManager:PamelaHersperger
MarketingAssistant:BarrieReinhold
©2005byPearsonEducation,Inc.
UpperSaddleRiver,NewJersey07458
Theauthorsandpublisherofthisbookhaveusedtheirbest
effortsinpreparingthisbook.Theseeffortsincludethe
development,research,andtestingofthetheoriesand
programstodeterminetheireffectiveness.Theauthorsand
publishermakenowarrantyofanykind,expressedorimplied,
withregardtotheseprogramsortothedocumentation
containedinthisbook.Theauthorsandpublishershallnotbe
liableinanyeventforincidentalorconsequentialdamagesin
connectionwith,orarisingoutof,thefurnishing,performance,
oruseoftheseprograms.
Manyofthedesignationsusedbymanufacturersandsellersto
distinguishtheirproductsareclaimedastrademarksand
registeredtrademarks.Wherethosedesignationsappearinthis
book,andPrenticeHallandtheauthorswereawareofa

trademarkclaim,thedesignationshavebeenprintedininitial
capsorallcaps.Allproductnamesmentionedremain


trademarksorregisteredtrademarksoftheirrespectiveowners.
Allrightsreserved.Nopartofthisbookmaybereproduced,in
anyformorbyanymeans,withoutpermissioninwritingfrom
thepublisher.
PrintedintheUnitedStatesofAmerica
10987654321
PearsonEducationLtd.,London
PearsonEducationAustraliaPty.Ltd.,Sydney
PearsonEducationSingapore,Pte.Ltd.
PearsonEducationNorthAsiaLtd.,HongKong
PearsonEducationCanada,Inc.,Toronto
PearsonEducaciondeMexico,S.A.deC.V.
PearsonEducationJapan,Tokyo
PearsonEducationMalaysia,Pte.Ltd.
PearsonEducation,Inc.,UpperSaddleRiver,NewJersey

[Pagevi]

Trademarks
BorlandandC++Builderaretrademarksorregistered
trademarksofBorland.
CygwinisatrademarkandcopyrightedworkofRedHat,Inc.in
theUnitedStatesandothercountries.
DiveIntoisaregisteredtrademarkofDeitel&Associates,Inc.
GNUisatrademarkoftheFreeSoftwareFoundation.
JavaandallJava-basedmarksaretrademarksorregistered

trademarksofSunMicrosystems,Inc.intheUnitedStatesand


othercountries.PearsonEducationisindependentofSun
Microsystems,Inc.
LinuxisaregisteredtrademarkofLinusTorvalds.
Microsoft,Microsoft®InternetExplorerandtheWindowslogo
areeitherregisteredtrademarksortrademarksofMicrosoft
CorporationintheUnitedStatesand/orothercountries.
Netscapebrowserwindow©2004NetscapeCommunications
Corporation.Usedwithpermission.NetscapeCommunications
hasnotauthorized,sponsored,endorsed,orapprovedthis
publicationandisnotresponsibleforitscontent.
ObjectManagementGroup,OMG,UnifiedModelingLanguage
andUMLaretrademarksofObjectManagementGroup,Inc.

[Pagevii]

Dedication
To:
StephenClamage
ChairmanoftheJ16committee,"ProgrammingLanguage
C++"thatisresponsiblefortheC++standard;Senior
StaffEngineer,SunMicrosystems,Inc.,SoftwareDivision.
DonKostuch
IndependentConsultant
andMikeMiller
FormerViceChairmanandCoreLanguageWorkingGroup



ChairmanoftheJ16committee,"ProgrammingLanguage
C++;"SoftwareDesignEngineer,EdisonDesignGroup,
Inc.
Foryourmentorship,friendship,andtirelessdevotionto
insistingthatwe"getitright"andhelpingusdoso.
ItisaprivilegetoworkwithsuchconsummateC++
professionals.
HarveyM.DeitelandPaulJ.Deitel


[Pageii]


×