Đang chuẩn bị liên kết để tải về tài liệu:
Lecture Programming in C++ - Chapter 14: Object oriented design
Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Lecture Programming in C++ - Chapter 14: Object oriented design. In this chapter, you will learn how to: Use the special class specifiers static and const, work with friend functions and classes, read some UML and the difference between "has a" and "uses" relationships. | Chapter 14 – Object Oriented Design Copy Constructor Called with an object as an argument General declarator Class :: Class (Class& alias) Class is class name alias is alias for object being copied Values directly copied can be listed in initialization section :member1 (alias.member1), member2 (alias.member2) Lesson 14.1 Destructor Member function automatically called when object goes out of scope Name of destructor function required to be class name preceded by tilde (~) Cannot return a value or contain arguments General destructor declaration and declarator Lesson 14.1 ~Class ( ); Class :: ~Class ( ) Declaration in class definition Declarator in function definition static Storage Class Specifier Gives permanent storage for variable Persists through entire program execution Memory accessibility static used with local variable Access allowed only from function where declared static used with global variable Access allowed from file with declaration static used with data member of a . | Chapter 14 – Object Oriented Design Copy Constructor Called with an object as an argument General declarator Class :: Class (Class& alias) Class is class name alias is alias for object being copied Values directly copied can be listed in initialization section :member1 (alias.member1), member2 (alias.member2) Lesson 14.1 Destructor Member function automatically called when object goes out of scope Name of destructor function required to be class name preceded by tilde (~) Cannot return a value or contain arguments General destructor declaration and declarator Lesson 14.1 ~Class ( ); Class :: ~Class ( ) Declaration in class definition Declarator in function definition static Storage Class Specifier Gives permanent storage for variable Persists through entire program execution Memory accessibility static used with local variable Access allowed only from function where declared static used with global variable Access allowed from file with declaration static used with data member of a class access allowed by all objects of the class Lesson 14.2 static Data Members Shared by all objects of a class Declared by keyword static in class definition Initialized outside any member functions type Class :: variable = value; Accessible and modifiable by invoking ordinary member function on any object Accessible and modifiable by invoking static member function on class Specified as public or private in accessibility Lesson 14.2 static Function Members Declared static by preceding declaration with keyword static Not necessarily invoked using object and dot operator Without keyword static in function declarator Not allowed to access to nonstatic data and function members Allowed to be called even when no class objects exist in program Lesson 14.2 const Special Qualifier Data members and objects qualified by const cannot be modified after initialization Function members qualified with const do not modify invoking object's data Lesson 14.3 Pointer Data Members with const Three .