资源描述:
《Object-orientedProgrammingwithANSI-C.pdf》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库。
1、___________________________________________________________________________vPrefaceNoprogrammingtechniquesolvesallproblems.Noprogramminglanguageproducesonlycorrectresults.Noprogrammershouldstarteachprojectfromscratch.Object-orientedprogrammingisthecurrentcure-all—a
2、lthoughithasbeenaroundformuchmorethentenyears.Atthecore,thereislittlemoretoitthenfinallyapplyingthegoodprogrammingprincipleswhichwehavebeentaughtformorethentwentyyears.C++(Eiffel,Oberon-2,Smalltalk...takeyourpick)istheNewLanguagebecauseitisobject-oriented—althoughy
3、ouneednotuseitthatwayifyoudonotwantto(orknowhowto),anditturnsoutthatyoucandojustaswellwithplainANSI-C.Onlyobject-orientationpermitscodereusebetweenpro-jects—althoughtheideaofsubroutinesisasoldascomputersandgoodprogram-mersalwayscarriedtheirtoolkitsandlibrarieswitht
4、hem.Thisbookisnotgoingtopraiseobject-orientedprogrammingorcondemntheOldWay.WearesimplygoingtouseANSI-Ctodiscoverhowobject-orientedpro-grammingisdone,whatitstechniquesare,whytheyhelpussolvebiggerprob-lems,andhowweharnessgeneralityandprogramtocatchmistakesearlier.Alo
5、ngthewayweencounterallthejargon—classes,inheritance,instances,linkage,methods,objects,polymorphisms,andmore—butwetakeitoutoftherealmofmagicandseehowittranslatesintothethingswehaveknownanddoneallalong.IhadfundiscoveringthatANSI-Cisafull-scaleobject-orientedlanguage.
6、TosharethisfunyouneedtobereasonablyfluentinANSI-Ctobeginwith—feelingcomfortablewithstructures,pointers,prototypes,andfunctionpointersisamust.Workingthroughthebookyouwillencounterallthenewspeak—accordingtoOrwellandWebsteralanguage‘‘designedtodiminishtherangeofthough
7、t’’—andIwilltrytodemonstratehowitmerelycombinesallthegoodprogrammingprinci-plesthatyoualwayswantedtoemployintoacoherentapproach.Asaresult,youmaywellbecomeamoreproficientANSI-Cprogrammer.Thefirstsixchaptersdevelopthefoundationsofobject-orientedprogrammingwithANSI-C.
8、Westartwithacarefulinformationhidingtechniqueforabstractdatatypes,addgenericfunctionsbasedondynamiclinkageandinheritcodebyjudiciouslengtheningofs