资源描述:
《Object-oriented programming with ANSI-C.pdf》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库。
1、___________________________________________________________________________vPrefaceNoprogrammingtechniquesolvesallproblems.Noprogramminglanguageproducesonlycorrectresults.Noprogrammershouldstarteachprojectfromscratch.Object-orientedprogrammingisthecurrentcure-all—althoughithasbeenaround
2、formuchmorethentenyears.Atthecore,thereislittlemoretoitthenfinallyapplyingthegoodprogrammingprincipleswhichwehavebeentaughtformorethentwentyyears.C++(Eiffel,Oberon-2,Smalltalk...takeyourpick)istheNewLanguagebecauseitisobject-oriented—althoughyouneednotuseitthatwayifyoudonotwantto(orknow
3、howto),anditturnsoutthatyoucandojustaswellwithplainANSI-C.Onlyobject-orientationpermitscodereusebetweenpro-jects—althoughtheideaofsubroutinesisasoldascomputersandgoodprogram-mersalwayscarriedtheirtoolkitsandlibrarieswiththem.Thisbookisnotgoingtopraiseobject-orientedprogrammingorcondemnt
4、heOldWay.WearesimplygoingtouseANSI-Ctodiscoverhowobject-orientedpro-grammingisdone,whatitstechniquesare,whytheyhelpussolvebiggerprob-lems,andhowweharnessgeneralityandprogramtocatchmistakesearlier.Alongthewayweencounterallthejargon—classes,inheritance,instances,linkage,methods,objects,po
5、lymorphisms,andmore—butwetakeitoutoftherealmofmagicandseehowittranslatesintothethingswehaveknownanddoneallalong.IhadfundiscoveringthatANSI-Cisafull-scaleobject-orientedlanguage.TosharethisfunyouneedtobereasonablyfluentinANSI-Ctobeginwith—feelingcomfortablewithstructures,pointers,prototy
6、pes,andfunctionpointersisamust.Workingthroughthebookyouwillencounterallthenewspeak—accordingtoOrwellandWebsteralanguage‘‘designedtodiminishtherangeofthought’’—andIwilltrytodemonstratehowitmerelycombinesallthegoodprogrammingprinci-plesthatyoualwayswantedtoemployintoacoherentapproach.Asar
7、esult,youmaywellbecomeamoreproficientANSI-Cprogrammer.Thefirstsixchaptersdevelopthefoundationsofobject-orientedprogrammingwithANSI-C.Westartwithacarefulinformationhidingtechniqueforabstractdatatypes,addgenericfunctionsbasedondynamiclinkageandinheritcodebyjudiciouslengtheningofs