计算机C语言专业外文翻译.docx
- 文档编号:29486354
- 上传时间:2023-07-23
- 格式:DOCX
- 页数:6
- 大小:19.52KB
计算机C语言专业外文翻译.docx
《计算机C语言专业外文翻译.docx》由会员分享,可在线阅读,更多相关《计算机C语言专业外文翻译.docx(6页珍藏版)》请在冰豆网上搜索。
计算机C语言专业外文翻译
计算机C语言专业外文翻译
CAHistoryofCCandCTheCprogramminglanguagewascreatedinthespiritoftheCandCprogramminglanguages.Thisaccountsforitspowerfulfeaturesandeasylearningcurve.ThesamecantbesaidforCandCbutbecauseCwascreatedfromthegroundupMicrosofttookthelibertyofremovingsomeofthemoreburdensomefeatures—suchas
pointers.ThissectiontakesalookattheCandClanguagestracingtheirevolutionintoC.TheCprogramminglanguagewasoriginallydesignedforuseontheUNIXoperatingsystem.CwasusedtocreatemanyUNIXapplicationsincludingaCcompilerandwaseventuallyusedtowriteUNIXitself.ItswidespreadacceptanceintheacademicarenaexpandedtoincludethecommercialworldandsoftwarevendorssuchasMicrosoftandBorlandreleasedCcompilersforpersonalcomputers.TheoriginalWindowsAPIwasdesignedtoworkwithWindowscodewritteninCandthelatestsetofthecoreWindowsoperatingsystemAPIsremaincompatiblewithCtothisday.FromadesignstandpointClackedadetailthatotherlanguagessuchasSmalltalkhadalreadyembraced:
theconceptofanobject.YoulllearnmoreaboutobjectsinChapter8quotWritingObject-OrientedCode.quotFornowthinkofanobjectasacollectionofdataandasetofoperationsthatcanbeperformedonthatdata.Object-stylecodingcouldbeaccomplishedusingCbutthenotionofanobjectwasnotenforcedbythelanguage.Ifyouwantedtostructureyourcodetoresembleanobjectfine.Ifyoudidntfine.Creallydidntcare.Objectswerentaninherentpartofthelanguagesomanypeopledidntpaymuchattentiontothisprogrammingparadigm.Afterthenotionofobject-orienteddevelopmentbegantogainacceptanceitbecameclearthatCneededtoberefinedtoembracethisnewwayofthinkingaboutcode.Cwascreatedtoembodythisrefinement.ItwasdesignedtobebackwardlycompatiblewithCsuchthatallCprogramswouldalsobeCprogramsandcouldbecompiledwithaCcompiler.ThemajoradditiontotheClanguagewassupportforthisnewobjectconcept.TheClanguageaddedsupportforclasseswhicharequottemplatesquotofobjectsandenabledanentiregenerationofCprogrammerstothinkintermsofobjectsandtheirbehavior.TheClanguageisanimprovementoverCbutitstillhassomedisadvantages.CandCcanbehardtogetahandleon.Unlikeeasy-to-uselanguageslikeVisualBasicCandCareveryquotlowlevelquotandrequireyoutodoalotofcodingtomakeyourapplicationrunwell.Youhavetowriteyourowncodetohandleissuessuchasmemorymanagementanderrorchecking.CandCcanresultinverypowerfulapplicationsbutyouneedtoensurethatyourcodeworkswell.Onebugcanmaketheentireapplicationcrashorbehaveunexpectedly.BecauseoftheCdesigngoalofretainingbackwardcompatibilitywithCCwasunabletobreakawayfromthelowlevelnatureofC.MicrosoftdesignedCtoretainmuchofthesyntaxofCandC.DeveloperswhoarefamiliarwiththoselanguagescanpickupCcodeandbegincodingrelativelyquickly.ThebigadvantagetoChoweveristhatitsdesignerschosenottomakeitbackwardlycompatiblewithCandC.Whilethismayseemlikeabaddealitsactuallygoodnews.CeliminatesthethingsthatmakesCandCdifficulttoworkwith.BecauseallCcodeisalsoCcodeChadtoretainalloftheoriginalquirksanddeficienciesfoundinC.CisstartingwithacleanslateandwithoutanycompatibilityrequirementssoitcanretainthestrengthsofitspredecessorsanddiscardtheweaknessesthatmadelifehardforCandCprogrammers.IntroducingCCthenewlanguageintroducedinthe.NETFrameworkisderivedfromC.HoweverCisamodernobjected-orientedfromthegrounduptype-safelanguage.LanguagefeaturesThefollowingsectionstakeaquicklookatsomeofthefeaturesoftheClanguage.Ifsomeoftheseconceptsdontsoundfamiliartoyoudont
worry.Allofthemarecoveredindetailinlaterchapters.ClassesAllcodeanddatainCmustbeenclosedinaclass.Youcantdefineavariableoutsideofaclassandyoucantwriteanycodethatsnotinaclass.Classescanhaveconstructorswhichexecutewhenanobjectoftheclassiscreatedandadestructorwhichexecuteswhenanobjectoftheclassisdestroyed.Classessupportsingleinheritanceandallclassesultimatelyderivefromabaseclasscalledobject.Csupportsversioningtechniquestohelpyourclassesevolveovertimewhilemaintainingcompatibilitywithcodethatusesearlierversionsofyourclasses.AsanexampletakealookataclasscalledFamily.Thisclasscontainsthetwostaticfieldsthatholdthefirstandlastnameofafamilymemberaswellasamethodthatreturnsthefullnameofthefamilymember.classClass1publicstringFirstNamepublicstringLastNamepublicstringFullNamereturnFirstNameLastNameNoteSingleinheritancemeansthataCclasscaninheritfromonlyonebaseclass.Cenablesyoutogroupyourclassesintoacollectionofclassescalledanamespace.Namespaceshavenamesandcanhelporganizecollectionsofclassesintologicalgroupings.AsyoubegintolearnCitbecomesapparentthatallnamespacesrelevanttothe.NETFrameworkbeginwithSystem.MicrosofthasalsochosentoincludesomeclassesthataidinbackwardscompatibilityandAPIaccess.TheseclassesarecontainedwithintheMicrosoftnamespace.DatatypesCletsyouworkwithtwotypesofdata:
valuetypesandreferencetypes.Valuetypesholdactualvalues.Referencetypesholdreferencestovaluesstoredelsewhereinmemory.Primitivetypessuchascharintandfloataswellasenumeratedvaluesandstructuresarevaluetypes.Referencetypesholdvariablesthatdealwithobjectsandarrays.Ccomeswithpredefinedreferencetypesobjectandstringaswellaspredefinedvaluetypessbyteshortintlongbyteushortuintulongfloatdoubleboolcharanddecimal.Youcanalsodefineyourownvalueandreferencetypesinyourcode.Allvalueandreferencetypesultimatelyderivefromabasetypecalledobject.Callowsyoutoconvertavalueofonetypeintoavalueofanothertype.Youcanworkwithbothimplicitconversionsandexplicitconversions.Implicitconversionsalwayssucceedanddontloseanyinformationforexampleyoucanconvertaninttoalongwithoutlosinganydatabecausealongislargerthananint.Explicitconversionsmaycauseyoutolosedataforexampleconvertingalongintoanintmayresultinalossofdatabecausealongcanholdlargervaluesthananint.Youmustwriteacastoperatorintoyourcodetomakeanexplicitconversionhappen.Cross-ReferenceRefertoChapter3quotWorkingwithVariablesquotformoreinformationaboutimplicitandexplicitconversions.Youcanworkwithbothone-dimensionalandmultidimensionalarraysinC.Multidimensionalarrayscanberectangularinwhicheachofthearrayshasthesamedimensionsorjaggedinwhicheachofthearrayshasdifferentdimensions.Classesandstructurescanhavedatamemberscalledpropertiesandfields.Fieldsarevariablesthatareassociatedwiththeenclosingclassorstructure.YoumaydefineastructurecalledEmployeeforexamplethathasafieldcalledName.IfyoudefineavariableoftypeEmployeecalledCurrentEmployeeyoucanretrievetheemployeesnamebywritingCurrentEmployee.Name.Propertiesarelikefieldsbutenableyoutowritecodetospecifywhatshouldhappenwhencodeaccessesthevalue.IftheemployeesnamemustbereadfromadatabaseforexampleyoucanwritecodethatsaysquotwhensomeoneasksforthevalueoftheNamepropertyreadthenamefromthedatabaseandreturnthenameasastring.quotFunctionsAfunctionisacallablepieceofcodethatmayormaynotreturnavaluetothecodethatoriginallycalledit.AnexampleofafunctionwouldbetheFullNamefunctionshownearlierinthischapterinthe
Familyclass.Afunctionisgenerallyassociatedtopiecesofcodethatreturninformationwhereasamethodgenerallydoesnotreturninformation.Forourpurposeshoweverwegeneralizeandrefertothembothasfunctions.Functionscanhavefourkindsofparameters:
Inputparametershavevaluesthataresentintothefunctionbutthefunctioncannotchangethosevalues.Outputparametershavenovaluewhentheyaresentintothefunctionbutthefunctioncangivethemavalueandsendthevaluebacktothecaller.Referenceparameterspassinareferencetoanothervalue.Theyhaveavaluecomingintothefunctionandthatvaluecanbechangedinsidethefunction.Paramsparametersdefineavariablenumberofargumentsinalist.CandtheCLRworktogethertoprovideautomaticmemorymanagement.Youdontneedtowritecodethatsaysquotallocateenoughmemoryforanintegerquotorquotfreethememorythatthisobjectwasusing.quotTheCLRmonitorsyourmemoryusageandautomaticallyretrievesmorewhenyouneedit.ItalsofreesmemoryautomaticallywhenitdetectsthatitisnolongerbeingusedthisisalsoknownasGarbageCollection.Cprovidesavarietyofoperatorsthatenableyoutowritemathematicalandbitwiseexpressions.Manybutnotalloftheseoperatorscanberedefinedenablingyoutochangehowtheoperatorswork.Csupportsalonglistofstatementsthatenableyoutodefinevariousexecutionpathswithinyourcode.Flowcontrolstatementsthatusekeywordssuchasifswitchwhileforbreakandcontinueenableyourcodetobranchoffintodifferentpathsdependingonthevaluesofyourvariables.Classescancontaincodeanddata.Eachclassmemberhassomethingcalledanaccessibilityscopewhichdefinesthemembersvisibilitytootherobjects.Csupportspublicprotectedinternalprotectedinternalandprivateaccessibilityscopes.VariablesVariablescanbedefinedasconstants.Constantshavevaluesthatcannotchangeduringtheexecutionofyourcode.Thevalueofpiforinstanceisagoodexampleofaconstantbecauseitsvaluewontbechanging
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 计算机 语言 专业 外文 翻译