欢迎来到天天文库
浏览记录
ID:59437605
大小:920.00 KB
页数:88页
时间:2020-09-18
《2019年 (资料抽象化)ppt课件.ppt》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、Chapter7:ClassesPartIIOutline7.1Introduction7.2const(Constant)ObjectsandconstMemberFunctions7.3Composition:ObjectsasMembersofClasses7.4friendFunctionsandfriendClasses7.5UsingthethisPointer7.6DynamicMemoryManagementwithOperatorsnewanddelete7.7staticClassM
2、embers7.8DataAbstractionandInformationHiding7.8.1Example:ArrayAbstractDataType7.8.2Example:StringAbstractDataType7.8.3Example:QueueAbstractDataType7.9ContainerClassesandIterators7.10ProxyClasses箕环狸易惭蹄抠殃槐山伟昏援另吹惑监簇侣怎巨谋亥呼师铅铱腑艘交溅吗(资料抽象化)(资料抽象化)17.1Introduct
3、ionClassesDataabstraction(資料抽象化)Object-basedprogramming(OBP)Chapters6-8Inheritance(繼承)andpolymorphism(多型)Chapters9and10癸楞梅鉴虹摘涩民以鼎啥包蔓御败平粪丈烧壳瓦汐开弥碧离忧浮猩挂灸咱(资料抽象化)(资料抽象化)27.2const(Constant)ObjectsandconstMemberFunctionsPrincipleofleastprivilege(最少特權)Onlyallowmodif
4、icationofnecessaryobjectsKeywordconst(常數)SpecifyobjectnotmodifiableCompilererrorifattempttomodifyconstobjectExampleconstTimenoon(12,0,0);DeclaresconstobjectnoonofclassTimeInitializesto12奋渣伐附剁见瘤敲驴诱搁狸馒鹊简猜伪早费傀韩僧彻趋羊玻昧廊宫墓窿谆(资料抽象化)(资料抽象化)37.2const(Constant)Objectsa
5、ndconstMemberFunctionsconstmemberfunctions(常數成員函數)MemberfunctionsforconstobjectsmustalsobeconstCannotmodifyobjectSpecifyconstinbothprototypeanddefinitionPrototypeAfterparameterlistDefinitionBeforebeginningleftbrace帖腹嘴氟睁极倒顺解克校仪涡魔艾聘道连部拯霜匙被畸辆枣纫绵踌梦将枕(资料抽象化)(资料抽象化
6、)47.2const(Constant)ObjectsandconstMemberFunctionsConstructorsanddestructorsCannotbeconstMustbeabletomodifyobjectsConstructorInitializesobjectsDestructorPerformsterminationhousekeeping室辅催掏京脯怂雍页脓贾流梯传琶述臭睦稚哼彻刻访汪丘扮汁楔臣疚曝正(资料抽象化)(资料抽象化)5time5.h(1of2)1//Fig.7.1:time
7、5.h2//DefinitionofclassTime.3//Memberfunctionsdefinedintime5.cpp.4#ifndefTIME5_H5#defineTIME5_H67classTime{89public:10Time(int=0,int=0,int=0);//defaultconstructor1112//setfunctions13voidsetTime(int,int,int);//settime14voidsetHour(int);//sethour15voidsetMinute
8、(int);//setminute16voidsetSecond(int);//setsecond1718//getfunctions(normallydeclaredconst)19intgetHour()const;//returnhour20intgetMinute()const;//returnminute21intgetSecond()const;//retur
此文档下载收益归作者所有