Tải bản đầy đủ (.pdf) (1,550 trang)

C++ for business programming, 2nd ed 2006

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 (6.87 MB, 1,550 trang )




Tableof

Contents
• Index

C++forBusinessProgramming,SecondEdition
ByJohnC.Molluzzo-PaceUniversity,NewYork
Publisher :PrenticeHall
PubDate :August02,2005
PrintISBN-10 :0-13-046700-6
PrintISBN-13 :978-0-13-046700-3
eTextISBN-10 :0-13-128899-7
eTextISBN-13 :978-0-13-128899-7
Pages :848


Thistextprovidesastudent-friendly,highlyreadableintroduction
toC++programmingforbeginningprogrammingstudents,
especiallythosemajoringinInformationSystemsandBusiness.It
guidesreadersthroughcompleteandcleardescriptionsofsample
programs,withawealthofexercisesincludedalongthewayto
helpreinforcetheimportantpointsofeachchapter.Throughout
thetext,astrongemphasisisplacedonbusinessapplications,
ratherthanthoseinmathematicsorcomputing.





C++forBusinessProgramming,SecondEdition
ByJohnC.Molluzzo-PaceUniversity,NewYork
Publisher :PrenticeHall
PubDate :August02,2005
PrintISBN-10 :0-13-046700-6

PrintISBN-13 :978-0-13-046700-3
Tableof eTextISBN-10 :0-13-128899-7

Contents eTextISBN-13 :978-0-13-128899-7
• Index
Pages :848














































Copyright
Preface
ChangesFromtheFirstEdition

ChapterOverview
PartI:C++Basics
Chapter1.IntroductiontoC++
WhyStudyC++?
Section1.1.OurFirstC++Program
Section1.2.IntegersandArithmetic
Section1.3.SolvingaProblemwithIntegers
Section1.4.OtherIntegerDataTypes
ChapterReview
Chapter2.RealNumbers
Section2.1.RealNumbers
Section2.2.SolvingProblemswithRealNumbers
Section2.3.MoreonArithmetic
Section2.4.ThreeDifficultiesWhenDisplayingDecimalNumberswith
cout
ChapterReview
Chapter3.Iteration
Section3.1.RelationConditions
Section3.2.IndefiniteIteration:ThewhileanddoStatements
Section3.3.SolvingaProblemwithIndefiniteIteration

xv
xvi
xvii
1
1
1
3
20
32

36
42
45
45
52
64
75
78
80
80
83
96





















































































Section3.4.DefiniteIteration
Section3.5.NestedLoops
ChapterReview
Chapter4.DecisionMaking
Section4.1.BasicDecisionMaking
Section4.2.CompoundConditionsTheLogicalOperators
Section4.3.NestedifStatements
Section4.4.TheswitchStatement
ChapterReview
Chapter5.Functions
Section5.1.TheFunctionConcept
Section5.2.User-DefinedFunctionsthatReturnaValue
Section5.3.ProgramsthatUseFunctions
Section5.4.TheC++MathLibraryFunctions
ChapterReview
Chapter6.Arrays
Section6.1.BasicConcepts
Section6.2.ProcessinganArray:forLoops
Section6.3.SortinganArray
Section6.4.MultidimensionalArrays
ChapterReview
Chapter7.PointersandC-Strings
Section7.1.Pointers
Section7.2.C-Strings
Section7.3.ArraysofStringsandPointers
ChapterReview

Chapter8.Pointers,Arrays,andFunctions
Section8.1.Pointers,ReferenceVariables,andFunctions
Section8.2.ArraysandFunctions
Section8.3.StringsandFunctions
Section8.4.TheStandardLibraryStringFunctions
Section8.5.CharacterClassificationandConversionFunctions
Section8.6.DynamicMemoryAllocation
ChapterReview
Chapter9.User-DefinedDataTypesandTables
Section9.1.ThetypedefandenumStatements
Section9.2.Structures
Section9.3.ArraysofStructures:Tables
Section9.4.Structures,Functions,andPointers

105
118
126
128
128
139
146
161
172
174
175
191
203
227
231
234

234
242
250
256
264
266
266
277
290
297
299
299
309
318
326
336
351
360
363
364
371
379
407




















































































ChapterReview
PartII:Object-OrientedProgramming
Chapter10.ThestringClass:AnIntroductiontoClassesandObjects
Section10.1.Objects,Classes,andObject-OrientedSystems
Section10.2.IntroductiontostringObjects
Section10.3.OperationsonstringObjects
Section10.4.MakingDecisionswithStrings
Section10.5.FunctionsandstringObjects
Section10.6.ManipulatingstringObjects
Section10.7.PuttingStringstoWork
Section10.8.ArraysofStrings
ChapterReview
Chapter11.Programmer-DefinedClassesandObjects
Section11.1.DeclaringObjectsandClasses
Section11.2.AMoreUsefulClassAccessorandMutatorMethods
Section11.3.ConstructorOverloadingandDestructors

Section11.4.DefaultArgumentsandObjectAssignment
Section11.5.GeneralFunctionOverloadingandFunctionTemplates
ChapterReview
Chapter12.ManipulatingObjects
Section12.1.UsingArrays,Pointers,andDynamicMemoryAllocation
Section12.2.TheCopyConstructor
Section12.3.UsingconstwithClasses
Section12.4.Objects,FunctionsandPointers
Section12.5.DynamicAllocationofObjects
Section12.6.StaticDataMembersandFunctions
ChapterReview
Chapter13.Inheritance
Section13.1.Inheritance
Section13.2.FunctionsinClassHierarchies
Section13.3.Polymorphism
Section13.4.AbstractBaseClasses
ChapterReview
Chapter14.Files
Section14.1.Input/OutputStreams
Section14.2.ProcessingaFileOneCharacterataTime
Section14.3.RandomFileAccess
Section14.4.BinarySequentialFileProcessing
Section14.5.RandomRecordInput/Output

424
426
426
427
430
438

444
446
451
458
470
473
476
476
487
496
504
511
517
519
520
528
540
556
581
588
598
600
601
618
629
649
661
664
665
686

692
699
709















































ChapterReview
Chapter15.SpecialTopics:Friends,OperatorOverloading,Macros,and
InlineFunctions
Section15.1.friendFunctions
Section15.2.OverloadingBasicArithmeticOperators
Section15.3.OverloadingAssignmentandthethisPointer
Section15.4.OverloadingtheInsertionandExtractionOperators
Section15.5.OverloadingCompoundAssignmentOperators
Section15.6.OverloadingRelationalOperators
Section15.7.OverloadingUnaryOperators
Section15.8.MacrosandInlineFunctions

ChapterReview
AppendixA.ComputersandData
SectionA.1.AModelComputerSystem
SectionA.2.DataRepresentationCharacters
SectionA.3.DataRepresentationIntegers
SectionA.4.DataRepresentationRealNumbers
ExercisesAppendixA
AppendixB.ProgramControl
SectionB.1.Sequence
SectionB.2.Selection
SectionB.3.Iteration
SectionB.4.Combinations
Index

727
730
731
738
745
754
763
768
775
779
788
791
791
794
797
799

800
802
802
803
808
812


Copyright
[Pageii]
LibraryofCongressCataloging-in-PublicationData
Molluzzo,JohnC.
C++forbusinessprogramming/JohnC.Molluzzo.--2nded.
p.cm.
Includesbibliographicalreferencesandindex.
ISBN0-13-046700-6
1.C++(Computerprogramlanguage)2.Business-Computerprograms.
I.Title.
HF5548.5.C125M652006
005.13'3-dc222005014365
VicePresidentandEditorialDirector,ECS:MarciaJ.
Horton
SeniorAcquisitionsEditor:TracyDunkelberger
EditorialAssistant:ChristiannaLee
ExecutiveManagingEditor:VinceO'Brien
ManagingEditor:CamilleTrentacoste
DirectorofCreativeServices:PaulBelfanti
ManagingEditor,AVManagementandProduction:Patricia



Burns
ArtEditor:GregoryDulles
CoverDesignDirector:JayneConte
CoverDesigner:KiwiDesigns
ManufacturingManager,ESM:AlexisHeydt-Long
ManufacturingBuyer:LisaMcDowell
ExecutiveMarketingManager:PamelaShaffer
MarketingAssistant:BarrieReinhold

©2006PearsonEducation,Inc.
PearsonPrenticeHall
PearsonEducation,Inc.
UpperSaddleRiver,NJ07458
Allrightsreserved.Nopartofthisbookmaybereproducedin
anyformorbyanymeans,withoutpermissioninwritingfrom
thepublisher.
PearsonPrenticeHall®isatrademarkofPearsonEducation,
Inc.
Theauthorandpublisherofthisbookhaveusedtheirbest
effortsinpreparingthisbook.Theseeffortsincludethe
development,research,andtestingofthetheoriesand
programstodeterminetheireffectiveness.Theauthorand
publishermakenowarrantyofanykind,expressedorimplied,
withregardtotheseprogramsorthedocumentationcontained
inthisbook.Theauthorandpublishershallnotbeliableinany


eventforincidentalorconsequentialdamagesinconnection
with,orarisingoutof,thefurnishing,performance,oruseof
theseprograms.

PrintedintheUnitedStatesofAmerica
10987654321
PearsonEducationLtd.,London
PearsonEducationAustraliaPty.Ltd.,Sydney
PearsonEducationSingapore,Pte.Ltd.
PearsonEducationNorthAsiaLtd.,HongKong
PearsonEducationCanada,Inc.,Toronto
PearsonEducacióndeMexico,S.A.deC.V.
PearsonEducationJapan,Tokyo
PearsonEducationMalaysia,Pte.Ltd.
PearsonEducation,Inc.,UpperSaddleRiver,NewJersey


[Pagexv]


Preface
C++forBusinessProgramming,SecondEditionisan
introductiontoC++programming.ThepowerofC++liesinits
object-orientedextensionsoftheClanguage.However,we
believethatforbeginningstudentsitisbesttolearnthebasics
ofprogrammingwithouttheextraencumbranceofhavingto
learnobject-orientedconcepts.Therefore,thebookisdivided
intotwosections.PartI,"BasicC++,"coverstheprocedural
partsofC++.PartII,"Object-OrientedProgramming,"covers
alltheessentialobject-orientedideasthroughinheritanceand
polymorphism.
UnlikemostbooksonC++,whichemphasizeapplicationsto
computingormathematics,thisbookemphasizesbusiness
applications.Therefore,thebookismostappropriatefor

businessandinformationsystemsstudents.Theentirebookcan
becoveredinonesemesterinaclassofstudentswhohavea
goodbackgroundinprogramminginanotherlanguage.Insuch
aclass,itispossibletoquicklycovertheessentialprogramming
constructsfromPartIandthenconcentrateonobject-oriented
conceptsandprogramminginPartII.Forstudentswhohave
littleprogrammingexperience,wesuggestcoveringPartIin
onesemesterandPartIIinasecondsemester.Thematerialin
PartIcanbesupplementedasneededbymaterialfrom
AppendixA,"ComputersandData,"andAppendixB,"Program
Control."
Throughoutthebook,weemphasizegoodpedagogy.
Eachchapterbeginswithasetoflearningobjectives.
Eachchapterendswithareviewsectionthatincludes
importantterms,achaptersummary,andreviewexercises.


Conceptsareexplainedinclear,understandablelanguage
andareillustratedbymanyfullyworked-outexamples.
Importantdefinitions,concepts,andrulesareappropriately
highlightedinnotes.
Programmingtipsandpitfallsarenotedinthemarginsof
thetext.
Oneofthebestwaystolearnaprogramminglanguageisto
readprogramsinthatlanguage.Therefore,everyimportant
ideaisillustratedinanexampleprogramandaccompanying
output.Thereareapproximately150completeprogramsin
thetext,eachofwhichweverycarefullyexplain.

[Pagexvi]

Thebookcontainsover800exercisesofvaryingtypesand
levelsofdifficulty.Theseexercisesareplacedattheendof
eachsectionratherthanattheendofeachchapterso
studentscanimmediatelyreinforcetheirnewknowledge.
Theseexercisesincludeexercises,experiments,and
programmingproblems.
Almosteverysectioncontainsexercisesonthesyntax
andsemanticsofC++.Mostoftheseareofthepaper
andpenciltype,althoughsomerequirewritingasimple
program.
Theexperiments,whichaskthestudenttoinvestigate
variousaspectsoftheC++language,areaunique
featureoftheexercisesections.Theexperiments
improvethestudent'sunderstandingofthefinerpoints
ofC++andhelpthestudentavoidcommonerrors
madebybeginningprogrammers.


Theprogrammingproblems,whichrangefrom10-20lineprogramstofull-scaleprojectsthatrequiretheuse
ofseveraluser-definedfunctionsand/orclasses,are
foundinmostsectionsofthebook.Thechapterillustrativeprogramsandprogrammingproblems
emphasizethebusinessapplicationsofC++.
ThebookconformstotheANSIC++standard.All
illustrativeprograms,however,caneasilybeadaptedto
nonstandardcompilers.Therefore,thebookcanbeused
withanyC++compiler.
Topicsareintroducedonaneed-to-knowbasistoprovide
motivationforthestudent.Therefore,thebookisnot
encyclopedicinitscoverageofC++.Insomecases,allthe
relevantideassurroundingatopicarespreadthroughout

severalsectionsorchapters.
AppendixA,"ComputersandData,"andAppendixB,
"ProgramControl,"providesupplementarymaterialfor
studentswhohaveaweakbackgroundincomputing.
AppendixesAandBcontainexercises.




[Pagexvi(continued)]

ChangesFromtheFirstEdition
Theterminologyandprogramconstructsusedhavebeen
updatedtoconformtocurrentpractice.
Severalsectionshavebeenlabeledasoptionaltoimprove
theflowoftheexpositionandenablethereaderand
instructortoconcentrateonthemoreimportantconcepts.
Insomechapters,notablyChapters2and5,materialhas
beenrearrangedtoimprovereadability.
AsectionontheC++MathLibraryfunctionshasbeen
addedtoChapter5.
Chapter12inthefirstedition,"FriendsandOperator
Overloading,"hasbeenmovedtotheendofthebook
(Chapter15)andhasbeenrenamed"SpecialTopics."
Thesectiontitled"MacrosandInlineFunctions,"hasbeen
movedfromChapter5to"SpecialTopics,"Chapter15.
ThebooknowdistinguishesC-stylestringsfromobjectsin
thestringclass.

[Pagexvii]

TohelpstudentstransitionfromPartItotheobjectorientedconceptsinPartII,weincludeatransitionchapter,
Chapter10,ontheC++stringclass.Object-oriented
conceptsareintroducedinthischaptersothatstudentscan
begininstantiating,using,andmanipulatingstringobjects


withouthavingtoworryabouthowtodefineaclass.




[Pagexvii(continued)]

ChapterOverview
Chapters19constitutePartI,"C++Basics."Chapter1,
"IntroductiontoC++,"introducesthestudenttothebasic
anatomyofaC++program.Itcoverstheinputandoutput
objectscinandcout,variables,integerdatatypes,and
arithmetic.Chapter2,"RealNumbers,"introducesthefloatand
doubledatatypes,thecompoundassignment,andincrement
anddecrementoperators.
Chapters3and4discussthebasiccontrolstructuresof
programming.Chapter3,"Iteration,"beginsbycovering
relationconditions.Thenitproceedstodiscussindefinite
iteration(thewhileanddostatements),definiteiteration(thefor
statement),andnestedloops.Chapter4,"DecisionMaking,"
coverstheifstatement,thelogicaloperators,nestedif
statements,andtheswitchstatement.
Chapter5introducestheimportantconceptoffunctions.
Becausethefunctionisnewtomoststudents,theconceptis

developedgraduallyfirstwithfunctionsthatdonotreturna
value,thenfunctionshavingarguments,and,finally,functions
thatreturnavalue.Wealsoincludeadiscussionofscopeand
duration.Anentiresectionisdevotedtodiscussingthree
programsthatusefunctions.Specialcareistakentoshowhow
theprogramlogicismodularizedintofunctions.Thechapter
endswithadiscussionoftheC++MathLibraryfunctions.
Chapter6,"Arrays,"showshowtoproperlydefineanarrayand
referenceitselements.Careistakentoshowhowtouseafor
looptoprocesstheelementsofanarray.Wealsocoverinsome
detailhowtosortanarrayusingthestandardbubblesort.
Finally,weshowhowtodeclareandprocessmultidimensional
arrays.


Chapter7introducespointers.Tohelpthestudentunderstand
thisimportanttopic,wequicklyputpointerstoworkby
applyingthemtoC-stylestrings.Illustrativeprogramsshow
howtocountcharactersinastring,displayastringinreverse,
andcountwordsinastring.Wealsodiscussarraysofstrings
andarraysofpointers.
Chapter8,"Pointers,Arrays,andFunctions,"reinforcesthe
student'sknowledgeofstringsandpointers.Callbyaddress
usingpointers,callbyreference,passingarraysasfunction
arguments,andfunctionsthatreturnpointersarediscussedin
detail.Wealsocoversomeusefulstringlibraryfunctionsand
characterclassificationandconversionfunctions.Wealso
discusstheuseofdynamicmemoryallocationusingthenewand
deleteoperators.
Chapter9,"User-DefinedDataTypesandTables,"discusses

typedef,enumeratedtypes,andstructures.Specialattentionis
giventotheuseofstructuresindefiningtables.Amajor
applicationinvolvessortingandsearchingatable(anarrayof
structures),includingbothsequentialandbinarysearches.The
chapteralsodiscussespointerstostructuresandusingthemas
functionarguments.Thischaptercanbeomittediftimeisa
consideration.

[Pagexviii]
Chapters1015comprisePartII,"Object-Oriented
Programming."Chapter10,"ThestringClass:AnIntroduction
toClassesandObjects,"servesasatransitionfromthe
emphasisonproceduralprogrammingofPartItoobject
orientation.Thechapterbeginswithageneraldiscussionof
object-orientedconcepts.Thenitillustratesthoseconcepts
usingthebuilt-instringclass.Sectionsdiscusshowtoperform
operationsonstringobjects,howtomanipulatestringobjects
andmakedecisionswithstringobjects,andhowtousestring
objectswithfunctions.Uponcompletionofthischapter,


studentsshouldbecomfortablewiththeobjectparadigm.
ThematerialinChapters1113isunifiedthroughthegradual
developmentofaSavingsAccountclass.Asnewobject-oriented
programming(OOP)conceptsareintroduced,theyareaddedto
theSavingsAccountclass.Chapter11introducesthereaderto
user-definedclassesandobjects.Wediscusshowtodeclarea
class,instantiateobjects,andcodemethods,constructors,and
destructors.Thechapterendswithathoroughdiscussionof
functionoverloadinganddefaultmethodarguments.

Chapter12,"ManipulatingObjects,"isthelongestchapterin
thebook.Someofthetopics,asoutlinedinthechapter
introduction,canbeomittedatfirstreading.Thechapterbegins
bydiscussinghowtoincludearrayandpointerinstance
variablesinaclassandhowtousedynamicmemoryallocation
inaconstructoranddestructor.Next,thechapterdiscussesthe
copyconstructorandwhenitisused.Themanywaysofusing
thekeywordconstinC++arethencoveredindetail.Wealso
discussfunctionsthatreturnobjectsaswellashowtopass
objectstofunctionsbyvalue,pointer,andreference.Severalof
theissuesrelatingtothedynamicallocationofobjectsare
coveredalongwiththeusesofstaticclassdatamembersand
methods.
Chapter13coverstheimportantconceptofinheritanceand
relatedideas.Weuseonemajorexamplethroughoutmostof
thechaptertounifythematerial.Afterintroducingthebasic
terminologyofinheritanceandhowtoconstructaclass
hierarchy,thechapterdiscussestheusesofmethodsinsucha
hierarchyandtheconceptofpolymorphism.Purevirtual
methodsandabstractbaseclassescompletethechapter.
Chapter14givesathoroughtreatmentoffileprocessingin
C++.Thechapterbeginswithadiscussionofinput/output(I/O)
streams,thestandardI/Oclasshierarchy,andhowtoprocess
simpletextfiles.Wethenshowhowtoprocessafileone
characteratatime.Next,wediscussbinaryfilesandthe


random-accessmethods.Theseideasarethenappliedtothe
problemsofprocessingabinarysequentialfileofrecordsandto
randomlyprocessingabinaryfileofrecords.Thechapter

culminateswitharandom-file-accessupdateprogram.
Chapter15coversseveralspecialtopics.Firstwediscussthe
conceptsoffriendfunctionsandoperatoroverloading.We
emphasizetheextensibilityoftheC++operatorsbyshowing
howtooverloadthearithmeticoperators,assignment,the
insertionandextractionoperators,thecompoundassignment
operators,therelationaloperators,andtheunaryoperators.We
concludethechapterwithadiscussionoftheuseofmacrosand
inlinefunctions.
IthankLauraSteeleandAlanAptofPrenticeHall,whomade
thefirsteditionofthisbookpossible.IalsothankKateHargett
andMikeGiacobbeforguidingmethroughthesecondedition.A
specialthankstoDeanSusanMerrittofPaceUniversitywho
gavethisprojectandmeherenthusiasticsupportforthemany
yearsittooktocomplete.ThanksalsotoChin-MeiHuangfor
herhelpfulcommentsonanearlyversionofthemanuscript,
AnnaKristoferitschforhelpingtosolvesomeofthechapter
exercisesand,especially,KenyataMillet,whospentmanylong
hourssolvingtheprogrammingproblemsandexercises.Ialso
thankEstherAmirifortheworkshedidontheexercisesand
programmingproblemsinchapter10.IthankProfessorGerald
WohlofPaceUniversityforhavingthecouragetousethefirst
draftofthisbookinhisC++courses,forcatchingmanyerrors
andtypos,andforprovidingmewithmanyhelpfulcomments
aboutthebook,andthemanyreadersandreviewerswho
providedvaluableinputtothesecondedition.Finally,Ithank
myfamilymywife,Maria,andmysons,JohnandCharlesforthe
helpandlovetheyhavegivenme.

[Pagexix]

Anoteaboutthetypefacesusedinthisbook:Intheprogram


outputs,datathattheuserinputsinresponsetoprogram
promptsissetinboldfacetodistinguishitfromoutputproduced
bytheprograms.
Reviewersforthisedition:
DennisD.Howard,UniversityofAlaskaAnchorage
NitinKale,UniversityofSouthernCalifornia
DanCalderwood,CollegeoftheRedwoods
SafooraFatima,DevryUniversity




[Page1]


PartI:C++Basics
Chapter1.IntroductiontoC++
Chapter2.RealNumbers
Chapter3.Iteration
Chapter4.DecisionMaking
Chapter5.Functions
Chapter6.Arrays
Chapter7.PointersandC-Strings
Chapter8.Pointers,Arrays,andFunctions
Chapter9.User-DefinedDataTypesandTables



[Page1(continued)]


Chapter1.IntroductiontoC++
OBJECTIVES
TowriteasimpleC++program
Tousecommentsinaprogram
Todeclarevariablesofdifferentintegerdatatypesand
decidewhentousethem
Tousethecoutoutputstreamtodisplaystringsandvariable
values
Tousethecininputstreamtoinputdata
Tousethearithmeticoperators
Tounderstandandusetheoperatorprecedencerules
Tosolvesimpleproblemsinvolvingintegers


[Page1(continued)]

WhyStudyC++?
C++,pronounced"Cplusplus,"isoneofthemostpopular
programminglanguagesusedtodevelopcomputerapplications.
ManycorporatecomputingdepartmentshaveadoptedC++as
thelanguageinwhichtodevelopin-houseapplications.Many
softwarevendorsuseC++towritetheirapplicationsoftware.
WhyisC++sopopularandwhyislearningitimportant?
C++isa"middle-level"language.Programminglanguages
canbecategorizedashigh-levelorlow-level.Assembly
languagesarelow-levellanguages.Anassemblylanguage
allowstheprogrammermaximumcontroloverthe

computersystem.Theprogrammercandirectlyinterface
withandcontrolthecomputer'shardwareandoperating
system.Thiscontrolcomesataprice,however.Assembly
languagesarehardtolearnbecausetheyarehighly
symbolicandtheprogrammermusttakecareofallthe
detailsoftheprogram.Assembly-languageprogramsare
alsodifficulttomaintainanddebug.Perhapsmost
important,assembly-languageprogramsarenotportable.
Anassembly-languageprogramisspecifictothehardware
andoperatingsystemofthecomputerplatformonwhichit
isdeveloped.Thus,youcannotdirectlyexecuteaPC
assemblylanguageprogramonaMacintosh.

[Page2]
Bycontrast,high-levellanguages,suchasCOBOL,Visual
Basic,andJava,areeasiertolearn,maintain,anddebug
thanassemblylanguages.Theprogramstatementsinsuch
languagesuseEnglishwordsandfamiliarmathematical


symbolstoexpressinstructionstothecomputer.Typically,
eachsuchinstructionreplacesseveralequivalentassemblylanguageinstructions.Thus,usingahigh-levellanguageis
easierthanusinganassemblylanguage.However,theprice
forthiseaseofuseisthelossofdirectcontroloverthe
computersystemthatyouhaveinanassemblylanguage.
C++,althoughitisamiddle-levellanguage(and,therefore
easiertolearnandusethananassemblylanguage),
containsmanyofthelow-levelcapabilitiesofanassembly
language.Thus,C++issometimescalleda"middle-level"
language.ItispossiblethroughC++toattainalmostas

muchcontroloverthecomputerasyoucanachievewithan
assemblylanguage.
C++isportable.Mosthigh-levellanguagesareportablein
thesensethataprogramwritteninahigh-levellanguage
shouldexecute,withminormodifications,onseveral
differentcomputersystems.C++isoneofthemost
portableofallthehigh-levellanguages.Properlywritten,a
C++programcanrunonseveralcomputersystemswithno
modifications.Portabilityisimportantbecauseitisnow
commonforabusinesstohaveseveraldifferenttypesof
computersystems(amainframe,minicomputers,
workstations,PCs,andMacintoshes).Aproperlywritten
applicationinC++shouldbeportabletomost,ifnotall,
thesesystems.Thus,portabilityeliminatesthecostof
developingtheapplicationseveraltimesfordifferent
platforms.
C++issmall.TheC++languagedoesnotcontainmanyof
thebuilt-infeaturespresentinotherprogramming
languages(suchasinVisualBasic),whichfurtherenhances
itsportability.Forexample,VisualBasichasabout150
keywords.(Akeywordisawordthathasspecialmeaning
inthelanguage.)C++,ontheotherhand,hasabout60
keywords.VisualBasicincludesextensivecapabilitiesto


×