计算机C语言专业外文翻译.docx

上传人:b****7 文档编号:15547625 上传时间:2023-07-05 格式:DOCX 页数:7 大小:19.60KB
下载 相关 举报
计算机C语言专业外文翻译.docx_第1页
第1页 / 共7页
计算机C语言专业外文翻译.docx_第2页
第2页 / 共7页
计算机C语言专业外文翻译.docx_第3页
第3页 / 共7页
计算机C语言专业外文翻译.docx_第4页
第4页 / 共7页
计算机C语言专业外文翻译.docx_第5页
第5页 / 共7页
计算机C语言专业外文翻译.docx_第6页
第6页 / 共7页
计算机C语言专业外文翻译.docx_第7页
第7页 / 共7页
亲,该文档总共7页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

计算机C语言专业外文翻译.docx

《计算机C语言专业外文翻译.docx》由会员分享,可在线阅读,更多相关《计算机C语言专业外文翻译.docx(7页珍藏版)》请在冰点文库上搜索。

计算机C语言专业外文翻译.docx

计算机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.classClass1publicstringFirstNamepublicstringLastNamepublicstring

FullNamereturnFirstNameLastNameNoteSingleinheritancemeansthataCclasscaninheritfromonlyonebaseclass.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.Thevalueofpiforinstanceisagoodexampleofaconstantbecauseitsvaluewontbechan

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 经管营销 > 经济市场

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2