Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Руководство_по_C++_CLI.doc
Скачиваний:
4
Добавлен:
01.07.2025
Размер:
8 Мб
Скачать
☆

4. Techniques of Using Variables 90

4.1   Constant Values 90

4.1.1   Introduction 90

4.1.2 Custom Constants 90

4.1.3 Language Constants 91

4.1.4 Using #define 92

4.2 Pointer Types 93

4.2.1   Introduction 93

4.2.2 Pointer Declaration 94

4.2.3 Pointer Initialization 95

4.2.4 A Pointer to a Pointer 97

4.2.5 Type Defining a Pointer 99

4.3 Pointers and Memory Management 101

4.3.1   Introduction 101

4.3.2 The new Operator 103

4.3.3 Practical Learning: Introducing Pointers 104

4.3.4 The delete Operator 105

4.3.5 Practical Learning: Deleting Pointers 105

4.4 Handle Types 107

4.4.1   Introduction 107

4.4.2 A Tracking Reference 107

4.4.3 Creating a Handle (дескриптор) 109

4.5 Using the Garbage Collector 110

4.5.1 Practical Learning: Using Handles 113

5. Introduction to Classes 115

5.1   A Review of Classes 115

5.1.1   Introduction 115

5.1.2 Practical Learning: Introducing Classes 115

5.2 Creating a Class 115

5.2.1 Practical Learning: Creating a Class 117

5.3 Value Types 118

5.3.1   Introduction 118

5.3.2 Practical Learning: Creating a Value Class 118

5.3.3 Creating a Value Type 119

5.3.4 Techniques of Initializing an Object 120

5.3.5 Practical Learning: Initializing an Object 123

5.3.6 Class Members Levels of Access 125

5.3.7 Practical Learning: Controlling the Access to a Class 127

5.3.8 Type-Defining a Class 127

5.3.9 Constant Objects 127

5.4 Union 129

5.4.1 Introduction 129

5.4.2 Using a Union 129

6. Classes and Memory Management 131

6.1 Pointers and Classes 131

6.1.1 Native References 131

6.1.2 Practical Learning: Introducing Pointers and Classes 131

6.2 Introduction to Pointers to Classes 132

6.2.1 Practical Learning: Introducing Pointers to Classes 132

6.2.2 Accessing the Members of a Pointer to a Class 133

6.2.3 Practical Learning: Accessing the Members of a Pointer to a Class 134

6.3 Allocating Memory on the Native Heap 135

6.3.1 Practical Learning: Allocating Memory on the Native Heap 135

6.3.2 De-Allocating Memory from the Native Heap 136

6.3.3 Practical Learning: De-Allocating Memory from the Native Heap 137

6.4 Classes and Pointers to Pointers 138

6.4.1 Declaring a Pointer to Pointer 138

6.5 Handle Types 140

6.5.1 Introduction 140

6.5.2 Practical Learning: Introducing Handles 140

6.5.3 A Tracking Reference 141

6.5.4 Creating a Handle 141

6.5.5 Practical Learning: Creating a Handle 143

6.6 Reference Types 143

6.6.1 Practical Learning: Creating a Reference Class 147

6.6.2 Accessing the Members of a Handle 147

6.6.3 Using the Garbage Collector 149

6.6.4 Practical Learning: Initializing a Handle 150

7. Classes Combinations and Inheritance 152

7.1 Class Combinations (агрегирование классов) 152

7.1.1   A Class as a Member Variable  152

7.1.2 Practical Learning: Using an Object as a Field 155

7.1.3 Introduction to Strings 157

7.1.4 Practical Learning: Using String Variables 159

7.1.5 A String as a Member Variable of a Class 160

7.1.6 Practical Learning: Using Strings as Fields 162

7.2 Inheritance 165