- 2
- 0
- 约8千字
- 约 18页
- 2018-05-10 发布于天津
- 举报
constructorsclass内一类特别的memberfunction其特性
C++ Overview 1999 amendment to c99 C with class Important concepts of C++ Function overload: different function using same function name. Enhance struct ? class (accept as a new type) Three access levels, (define friends of the class) Constructors (with function overload), Allow functions to be class members, Adopt operator as a class member function, Inheritance (layered) class structure. Implicit function overlaod: template. Use namespace: prefix to functions and classes. Function pass by reference (additional to value address) Using namespace old compiler #include iostream.h New compiler #include iostream; using namespace std; In headfile iostream is written as: namespace std { …. } all functions and classes are prefixed with “std::”, std::cin, std::cout.. specify the using namespace to omit the prefix. namespace namespace std { class iostream cout; …..; } defined in iostream #include iostream; std::cout “test\n”; #include iostream; using namespace std; cout “test\n”; Function overload (example) c++ can distinguish functions of same function name by their arguments (if distinguishable). Same function name with indistinguishable arguments ? compiler error. Class – an objectmembers and member functions (ex) New features of class Member function 使用 member function Constructor (example) Constructors -- 在創造 class 物件時, 賦與某些 data 的值 名字和 class 名字相同. 不須 function type, 也不須 return 的指令. 可以許多 constructor, 原則與 function overload 的原則相同. Write a polynomial class 練習九:把 newton 法的多項式改用 class 寫法. Operator 是否必須宣告為 friend? * * OOP: “object oriented programming” refers to structure of class. “Stream i/o” is a C++ class. class quadratic { private: // access leve: public, protect, private double a, b, c; // class members // class member functions public: void setcoef (double r1, double r2, double r3); double value(double
您可能关注的文档
- 2003年ct医师上岗证考试题-影像ftp.doc
- 2003年3mbpdf-山形大学附属图书馆.pdf
- 0910质量管理工作交流-上海食品药品检验所.ppt
- 2008年产业共性技术重大科技专项申报指南.doc
- 2008年高考理科综合全国卷ⅰ.doc
- 2009国家精品课程申报表本科-上海交大医学院课程中心0.doc
- 2010年江津中考语文试题答案-重庆江津第五中学校.doc
- 2011年检验主管技师考试真题及答案-真题园.pdf
- 2012述职述廉述法报告-句容第三中学.doc
- 2013年全国电力行业风电运检竞赛理论试题含答案.doc
- 2025-2026学年科普版七年级下册英语Unit7 Being a Smart Shopper素养测评卷(含答案).docx
- 2025-2026学年科普版七年级下册英语Unit10 Lending a Helping Hand素养测评卷(含答案).docx
- 2025-2026学年科普版七年级下册英语Unit11 Rules Matter素养测评卷(含答案).docx
- 2025-2026学年科普版七年级下册英语Unit12 Better Together素养测评卷(含答案).docx
- 2026年中考英语语法选择专题训练(含答案).docx
- 2026中考语文二轮学思并重,涵养君子之德论语十二章、虽有佳肴、大道之行也.docx
- 中考文言文常见文化常识梳理.docx
- 中考语文二轮:内修君子德外尽忠臣心诚子书出师表修身立德主题学习.docx
- 中考语文二轮:不一样的求学路一样的成长梦送东阳马生序劝学主题学习.docx
- 中考语文二轮:《陋室铭》《爱莲说》托物寓意主题学习.docx
原创力文档

文档评论(0)