- 2
- 0
- 约2.69万字
- 约 88页
- 2018-05-02 发布于河南
- 举报
c课件Lecture6
Lecture 67: Classes Contents Characteristics of OOP The definition and declaration of class Accessing manners Member of class Constructor Copy-constructor Destructor Class combination Static members OOP Language Main Viewpoint: OOP Language can describe the existing things (object) in the nature and their relations directly. Characteristics: Belonging to advanced language. Looking on the impersonal things as objects with some attributes and behaviors. Describing the objects with same attributes and behaviors as a Class. Realizing code reuse through inheritance and polymorphism. Example of structure: struct Date{ int year; int month; int day; }; void print(Date s){ cout.fill(0); coutsetw(4)s.year-setw(2)s.month-setw(2)s.day\n; cout.fill( ); } bool isLeapYear(Date d){ return (d.year % 4==0 d.year % 100!=0)||(d.year % 400==0);} #includeiostream #includeiomanip using namespace std; void main(){ Date d; d.year = 2000; d.month = 12; d.day = 6; if(isLeapYear(d)) print(d); } Example of class: class person{ char Name[20]; int Age; char Sex; public: void Register(char *, int, char); char *GetName(){return Name;} int GetAge(){return Age;} char GetSex(){return Sex;} void show() {coutGetName()\tGetAge()\t GetSex()endl;} }; void person::Register(char * name, int age, char sex) { strcpy(Name,name); Age=age; Sex=sex; } #includeiostream #include string using namespace std; void main() { char name[20],sex; int age; cinnameagesex; person per1; per1.Register(name,age,sex); per1.show();} OOP Language(continue) Basic concept of OOP Class Object Encapsulation and Concealment Inheritance and Reuse Polymorphism Class of OOP Object collection with the same attributes and behaviors. Providing abstract description for all objects belongs to the same class, which comprised attributes and behaviors. Class of OOP Relation between class and object:Class is an abstraction of objects with the same attributes and behaviors
您可能关注的文档
最近下载
- 如何找回误删微信好友,微信好友一键恢复.doc VIP
- 《蜀道难》课件34张.pptx VIP
- 《建筑地面工程施工质量验收规范》GB-50209-2022.pdf VIP
- 尼龙拉架织物的除油原理和产品资料.ppt VIP
- 2026年黑龙江农垦职业学院单招职业技能考试题库附答案.docx VIP
- 在带头强化政治忠诚、提高政治能力等“五个带头”方面个人对照检查材料【两篇】供参考2026.docx VIP
- 大病低保申请书.docx VIP
- 盐酸(31%)安全技术说明书.doc VIP
- 解读GB 6441-2025《生产安全事故分类与编码》.pptx
- FUJITSU 富士通存储系统ETERNUS DX60 S4 DX100 S4 DX200 S4, ETERNUS DX60 S3 DX100 S3 DX200 S3, ETERNUS DX500 S3 DX600 S3, ETERNUS DX8100 S3 DX8700 S3 DX8900 S3, ETERNUS AF250 AF650, ETERNUS DX200F 用户手册.pdf VIP
原创力文档

文档评论(0)