资源描述:
《计算机程序设计基础----c 简介》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、计算机程序设计基础----c简介Implementingencapsulation:{}inclassdeclarations9Introductiontoc++languageprogrammingZhengli,tsinghuauniversityencapsulationOOP'sbasepointExample:example:ClassClockexternalinterface{public:voidSetTime(intnewh.intNewM,intNewS);VoidShowTime();Private:intHour,Minute,Second;}
2、;Specificaccessboundaries10Introductiontoc++languageprogrammingZhengli,tsinghuauniversityInheritanceandderivedOOP'sbasepointSupporthierarchicalclassificationofamechanism,isoneofthec++supporthierarchicalclassificationmechanism,tosupportamechanismofhierarchicalclassificationAllowsprogramm
3、erstokeeptheoriginalclasscharacteristics,onthebasisofallowprogrammerstokeepintheoriginalclasscharacteristics,onthebasisofamoredetailedinstructions.Makemorespecificinstructions.Implementation:implementation:declarethederivedclass11Introductiontoc++languageprogrammingZhengli,tsinghuaunive
4、rsitypolymorphismOOP'sbasepointPolymorphism:thesamename,differentfunctionalimplementations.Polymorphism:thesamename,differentfunctionalimplementations.Objective:toachievetheunityofthebehavioridentification,toachievetheunityofthebehavioridentification,toreducethenumberofthestandardidenti
5、fiersintheprogram.Thenumberofdescriptors.Implementation:reloadfunctionsandvirtualfunctions12Introductiontoc++languageprogrammingZhengli,tsinghuauniversityClassandpairClassesinclassesinc++Classisasetofobjectswiththesamepropertiesandbehaviorofthecollection,acollectionofitforallbelongtothe
6、classobjectfortheunityofabstractdescription,fortheunityofabstractdescription,itsinternalbehaviorandsexaretwomajorparts.Themainpartsofsexandbehavior.Usingclassesenablesdataencapsulation,hiding,andusingclassestoencapsulate,hide,inherit,andderivedata.Inheritanceandderivation.Useclassiseasy
7、towritelarge,complexprograms,useclassiseasytowritelarge,complexprograms,itsmoldpieceofdegreehigherthanusefunctioninthehigherusefunctioninC.Thedegreeofblock-izationishigherthanthefunction.13Introductiontoc++languageprogrammingZhengli,tsinghuauniversityClassdeclarationsofclassesA