资源描述:
《软件专业毕业论文外文文献中英文翻译》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、软件专业毕业论文外文文献中英文翻译ObjectlandscapesandlifetimesTechnically,OOFisjustaboutabstractdatatyping,inheritance,andpolymorphism,butotherissuescanbeatleastasimportant.Theremainderofthissectionwillcovertheseissues.Oneofthemostimportantfactorsisthewayobjectsarecreatedanddes
2、troyed・Whereisthedataforanobjectandhowisthelifetimeoftheobjectcontrolled?Therearedifferentphilosophiesatworkhere・C++takestheapproachthatcontrolofefficiencyisthemostimportantissue,soitgivestheprogrammerachoice・Formaximumrun-timespeed,thestorageandlifetimecanbede
3、terminedwhiletheprogramisbeingwritten,byplacingtheobjectsonthestack(thesearesometimescalledautomaticorscopedvariables)orinthestaticstoragearea・Thisplacesapriorityonthespeedofstorageallocationandrelease,andcontrolofthesecanbeveryvaluableinsomesituations・However,
4、yousacrificeflexibilitybecauseyoumustknowtheexactquantity,lifetime,andtypeofobjectswhileyouTewritingtheprogram・Ifyouaretryingtosolveamoregeneralproblemsuchascomputer-aideddesign,warehousemanagement,orair-trafficcontrol,thisistoorestrictive.Thesecondapproachisto
5、createobjectsdynamicallyinapoolofmemorycalledtheheap.Inthisapproach,youdon'tknowuntilrun-timehowmanyobjectsyouneed,whattheirlifetimeis,orwhattheirexacttypeis.Thosearedeterminedatthespurofthemomentwhiletheprogramisrunning.Ifyouneedanewobject,yousimplymakeitonthe
6、heapatthepointthatyouneedit.Becausethestorageismanageddynamically,atrun-time,theamountoftimerequiredtoallocatestorageontheheapissignificantlylongerthanthetimetocreatestorageonthestack.(Creatingstorageonthestackisoftenasingleassemblyinstructiontomovethestackpoin
7、terdown,andanothertomoveitbackup.)Thedynamicapproachmakesthegenerallylogicalassumptionthatobjectstendtobecomplicated,sotheextraoverheadoffindingstorageandreleasingthatstoragewillnothaveanimportantimpactonthecreationofanobject.Inaddition,thegreaterflexibilityise
8、ssentialtosolvethegeneralprogrammingproblem・Javausesthesecondapproach,exclusively1.Everytimeyouwanttocreateanobject,youusethenewkeywordtobuildadynamicinstanceofthatobject・Th