- •1.3.1 Введение 13
- •1.5.1 Введение 37
- •2. Introduction to Variables 69
- •3. Data Types 72
- •4. Techniques of Using Variables 90
- •5. Introduction to Classes 115
- •5.4.1 Introduction 129
- •6. Classes and Memory Management 131
- •6.1.1 Native References 131
- •6.5.1 Introduction 140
- •7. Classes Combinations and Inheritance 152
- •7.2.1 Introduction 165
- •7.3.1 Introduction 171
- •8. Data Input/Output, Reading, and Formatting 173
- •8.1.1 Introduction 173
- •8.5.1 Introduction 189
- •8.6.1 Introduction 195
- •9. Introduction to Functions 201
- •10. Details on Passing Arguments 225
- •10.3.1 Introduction 237
- •11. Classes and Functions 242
- •11.1.2 Practical Learning: Introducing Data Reading 243
- •11.5.1 Introduction 264
- •12. Classes and their Methods 268
- •12.1.2 Practical Learning: Introducing Data Reading 268
- •12.4.1 Introduction 284
- •13. Class Construction and Destruction 290
- •13.3.1 Introduction 311
- •14. The Properties of a Class 315
- •14.1.1 Introduction 315
- •15. Function Pointers and Delegates 337
- •15.1.1 Introduction 337
- •15.3.1 Introduction 346
- •16. Introduction to Conditions 359
- •16.1.1 Introduction 359
- •16.2.1 Introduction 369
- •25.3.1 Introduction 543
- •26. Multi-Dimensional Arrays 556
- •26.1.1 Introduction 556
- •26.2.1 Introduction 566
- •27.1.1 Introduction 595
- •34. Введение в коллекции 743
- •35. Основы коллекций платформы .Net (Fundamentals of .Net Support For Collections) 779
- •36. Встроенные интерфейсы коллекций 797
- •37. Встроенные классы коллекций 841
- •1.1Основы
- •1.1.1Введение в с
- •1.1.2Библиотека Win32
- •1.1.4Библиотека mfc
- •1.1.6Microsoft Visual Basic
- •1.2The Microsoft .Net Framework
- •1.2.1 Введение
- •1.2.2 Помощь сом
- •1.3.1Введение
- •1.3.2Компилятор
- •1.3.3Компилятор cl
- •1.4.1Функция main()
- •Int main()
- •1.4.2Консольный ввод и вывод
- •Void main()
- •Int X; // Целочисленная переменная X
- •1.4.3Директива препроцессора #pragma region
- •1.4.4Использование дескрипторов
- •Void Handles()
- •1.4.5Одномерные массивы
- •Void SingleDimensional()
- •1.4.6Многомерные массивы
- •Void CreateArr2()
- •Void CreateJaggedArray()
- •1.4.7Передача массивов функциями
- •1.4.8Классы значения
- •1.4.9Классы ссылки
- •1.4.10Интерфейсы
- •1.4.11Абстрактные классы
- •Void Foo2(){} // и так тоже можно
- •Virtual int Foo()override {return 1024;}
- •Void Abstract()
- •1.4.12Запечатанные классы и виртуальные функции
- •Void Sealed()
- •1.4.13 Видимость компонентов классов и структур
- •1.4.14Свойства
- •Void SimpleIndexProp()
- •Value class p4
- •Int Value;
- •Void set(int X, int value)
- •Void DifficultIndexedProperty()
- •Int Value;
- •Void set(int X, int value)
- •Void DefaultIndexedProperty()
- •1.4.15Деструкторы классов
- •Value class DestructorValue
- •Void SimpleDestructorDemo()
- •Void DerivedClassDestructorDemo()
- •Void Destructors()
- •1.4.16 Приведение типов
- •Void DynamicCast()
- •If(icomp)
- •Void SafeCast()
- •Void ExplicitTypeConversion()
- •Void Casting()
- •1.4.17 Класс Array
- •IStructuralComparable, iStructuralEquatable
- •Void DemoArray()
- •1.4.18 Введение в коллекции
- •Void DemoArrayList()
- •1.5.1Введение
- •Include file.H
- •1.5.3Создание консольного приложения
- •1.5.4Открытие проекта
- •1.5.7Start Without Debugging
- •1.5.8Code Comments
- •Int main()
- •Int main()
- •I can write anything I want in it */
- •1.5.9Indentation
- •Int main()
- •I can write anything I want in it */
- •1.5.10Escape Sequences
- •1.6Введение в классы
- •Int protect()
- •Int main()
- •1.7.1Source Files
- •1.7.2Practical Learning: Creating a Source File
- •1.7.3Header Files
- •1.7.4Practical Learning: Creating a Header File
- •Int ShowWelcome();
- •Int cProperty::ShowWelcome()
- •1.7.5Assemblies
- •1.7.6Applications
- •1.7.7The Public and Private Objects of an Assembly
- •1.7.8Practical Learning: Controlling the Assembly Access of a Class
- •1.7.9Creating a Class
- •1.7.10Practical Learning: Creating a Class
- •1.8The Code Editor
- •1.8.1 Description
- •1.8.2The Tabs Bar
- •1.8.3The Scopes Combo Box
- •1.8.4The Functions Combo Box
- •1.8.5Code Colors
- •1.9The Solution Explorer
- •1.9.1 Introduction
- •1.9.2 Using the Solution Explorer
- •1.10The Class View
- •1.10.1Introduction
- •1.10.2Using the Class View
- •1.11Namespaces and Code Directives
- •1.11.1Introduction
- •1.11.2Practical Learning: Including a Class in a Namespace
- •1.11.3Using a Namespace
- •Int drive()
- •Int main()
- •Int main()
- •1.11.4Using Various Namespaces
- •Int drive()
- •Int showroof()
- •Int drive()
- •Int main()
- •Int drive()
- •Int main()
- •Int drive()
- •Int main()
- •1.11.5Nesting Namespaces
- •Int main()
- •Int main()
- •1.11.6Built-In Namespaces
- •1.11.6.1 The System Namespace
- •Int main()
- •1.11.6.2The std Namespace
- •Int main()
- •Int main()
- •Int main()
- •Int main()
- •1.12C Routines
- •Int main()
- •1.13Primary Details of Program Structure
- •1.13.1Preprocessors: #include
- •1.13.2Preprocessors: #define
- •Int main()
- •1.14Pragma Directives
- •1.14.1 Introduction
- •1.14.2Open Once
- •2. Introduction to Variables
- •2.1Introduction
- •2.2The Stack
- •2.3Variable Declaration
- •2.5Keywords
- •Internal initonly interface literal long
- •Value virtual void volatile wchar_t
- •3.Data Types
- •3.1Variable Initialization
- •3.2Introduction to Data Types
- •3.3Practical Learning: Introducing Data Types Applications
- •Int main()
- •3.4Integers
- •3.4.1Signed and Unsigned Numbers
- •3.4.2Bytes
- •Int main()
- •Int main()
- •3.4.3Practical Learning: Declaring a Byte Variable
- •Int main()
- •3.4.4Short Variables
- •Int main()
- •Int main()
- •Int main()
- •Int main()
- •Int main()
- •Int main()
- •3.4.5Integral Variables
- •Int main()
- •3.4.6Practical Learning: Declaring Unsigned Variables
- •3.4.7Long Integers
- •Int main()
- •3.4.8Practical Learning: Declaring Long Integers
- •Int main()
- •3.4.9Initializing an Integral Variable
- •3.5Characters
- •3.5.1 Symbolic Characters
- •Int main()
- •Int main()
- •3.5.2Unicode Characters
- •Int main()
- •Int main()
- •3.5.3Practical Learning: Using Character Variables
- •Int main()
- •3.6The String: a List of Characters
- •Int main()
- •3.7Decimal Numbers
- •3.7.1Floating-Point Variables
- •Int main()
- •3.7.2Practical Learning: Using a Single-Precision Variables
- •Int main()
- •3.7.3Double-Precision Variables
- •Int main()
- •3.7.4Practical Learning: Using a Single-Precision Variables
- •Int main()
- •3.7.5Initializing a Double-Precision Variable
- •Int main()
- •Int main()
- •3.8Variable Reference
- •3.8.1 The typedef Type Definition
- •Int main()
- •Int main()
- •3.9Native References
- •Int &Mine;
- •Int main()
- •Int main()
- •Its reference: 228
- •Int main()
- •Its reference: 228
- •Its reference: -15008
- •Its reference: 28114
- •Int main()
- •Int main()
- •3.10A Tracking Reference (отслеживаемая ссылка)
- •Int main()
- •Int % PropertyValue;
- •Int main()
- •4. Techniques of Using Variables
- •4.1 Constant Values
- •4.1.1 Introduction
- •Int main()
- •Int main()
- •4.1.2Custom Constants
- •Int main()
- •Int main()
- •4.1.3Language Constants
- •Int main()
- •4.1.4Using #define
- •Int main()
- •Int main()
- •4.2Pointer Types
- •4.2.1 Introduction
- •Int main()
- •4.2.2Pointer Declaration
- •Int main()
- •Int *Number;
- •4.2.3Pointer Initialization
- •Int main()
- •Int main()
- •Int main()
- •Int main()
- •Int *Number;
- •Int main()
- •Int *Number;
- •4.2.4A Pointer to a Pointer
- •Int main()
- •Int *pointer;
- •Int main()
- •Int *pointer;
- •Int **pointerToPointer;
- •Int main()
- •Int *pointer;
- •Int **pointerToPointer;
- •Int main()
- •Int *pointer;
- •Int **pointerToPointer;
- •4.2.5Type Defining a Pointer
- •Int *pAge;
- •4.3Pointers and Memory Management
- •4.3.1 Introduction
- •Int main()
- •Int main()
- •Int main()
- •4.3.2The new Operator
- •Int main()
- •4.3.3Practical Learning: Introducing Pointers
- •Int main()
- •4.3.4The delete Operator
- •Int main()
- •4.3.5Practical Learning: Deleting Pointers
- •Int main()
- •4.4Handle Types
- •4.4.1 Introduction
- •4.4.2A Tracking Reference
- •Int main()
- •Int main()
- •4.4.3Creating a Handle (дескриптор)
- •Int main()
- •Int main()
- •Item Price:
- •4.5Using the Garbage Collector
- •Int main()
- •Int main()
- •Item Price: 148.95
- •Int main()
- •Int main()
- •Item Price: 148.95
- •Int main()
- •Int main()
- •Int main()
- •4.5.1Practical Learning: Using Handles
- •Int main()
- •5. Introduction to Classes
- •5.1 A Review of Classes
- •5.1.1 Introduction
- •Int main()
- •Int Bedrooms;
- •Int YearBuilt;
- •5.1.2Practical Learning: Introducing Classes
- •Int main()
- •5.2Creating a Class
- •5.2.1Practical Learning: Creating a Class
- •5.3Value Types
- •5.3.1 Introduction
- •5.3.2Practical Learning: Creating a Value Class
- •5.3.3Creating a Value Type
- •5.3.4Techniques of Initializing an Object
- •Int Bedrooms;
- •Int YearBuilt;
- •Int main()
- •Int Bedrooms;
- •Int YearBuilt;
- •Int main()
- •Int Bedrooms;
- •Int YearBuilt;
- •5.3.5Practical Learning: Initializing an Object
- •Int main()
- •5.3.6Class Members Levels of Access
- •Int Bedrooms;
- •Int YearBuilt;
- •Int Bedrooms;
- •Int YearBuilt;
- •Int main()
- •Int Bedrooms;
- •Int YearBuilt;
- •Int main()
- •5.3.7Practical Learning: Controlling the Access to a Class
- •5.3.8Type-Defining a Class
- •Int Bedrooms;
- •Int YearBuilt;
- •Int main()
- •5.3.9Constant Objects
- •Int Bedrooms;
- •Int YearBuilt;
- •Int main()
- •5.4Union
- •5.4.1Introduction
- •Int YearBuilt;
- •Int YearBuilt;
- •Int main()
- •5.4.2Using a Union
- •Int Bedrooms;
- •Int YearBuilt;
- •Int main()
- •6.2Introduction to Pointers to Classes
- •6.2.1Practical Learning: Introducing Pointers to Classes
- •6.2.2Accessing the Members of a Pointer to a Class
- •Int main()
- •Int main()
- •6.2.3Practical Learning: Accessing the Members of a Pointer to a Class
- •Int Bedrooms;
- •Int YearBuilt;
- •Int main()
- •6.3Allocating Memory on the Native Heap
- •Int main()
- •6.3.1Practical Learning: Allocating Memory on the Native Heap
- •Int Bedrooms;
- •Int YearBuilt;
- •Int main()
- •Int main()
- •6.3.3Practical Learning: De-Allocating Memory from the Native Heap
- •Int Bedrooms;
- •Int YearBuilt;
- •Int main()
- •6.4Classes and Pointers to Pointers
- •6.4.1Declaring a Pointer to Pointer
- •Int main()
- •Int main()
- •Int main()
- •Int main()
- •6.5Handle Types
- •6.5.1 Introduction
- •6.5.2Practical Learning: Introducing Handles
- •Int main()
- •6.5.3A Tracking Reference
- •Int main()
- •6.5.4Creating a Handle
- •Int NumberOfBedrooms;
- •Int YearBuilt;
- •Int main()
- •Int main()
- •Int NumberOfBedrooms;
- •Int YearBuilt;
- •Int main()
- •6.5.5Practical Learning: Creating a Handle
- •Int main()
- •6.6Reference Types
- •Int NumberOfBedrooms;
- •Int YearBuilt;
- •Int main()
- •Int NumberOfBedrooms;
- •Int YearBuilt;
- •Int main()
- •Int NumberOfBedrooms;
- •Int YearBuilt;
- •Int main()
- •Int NumberOfBedrooms;
- •Int YearBuilt;
- •Int main()
- •Int NumberOfBedrooms;
- •Int YearBuilt;
- •Int main()
- •6.6.1Practical Learning: Creating a Reference Class
- •6.6.2Accessing the Members of a Handle
- •Int NumberOfBedrooms;
- •Int YearBuilt;
- •Int main()
- •Int NumberOfBedrooms;
- •Int YearBuilt;
- •Int main()
- •6.6.3Using the Garbage Collector
- •Int NumberOfBedrooms;
- •Int YearBuilt;
- •Int main()
- •6.6.4Practical Learning: Initializing a Handle
- •Int main()
- •7.Classes Combinations and Inheritance
- •7.1Class Combinations (агрегирование классов)
- •7.1.1 A Class as a Member Variable
- •Int Bedrooms;
- •Int YearBuilt;
- •Int main()
- •Int main()
- •7.1.2Practical Learning: Using an Object as a Field
- •7.1.3Introduction to Strings
- •Int main()
- •Int main()
- •7.1.4Practical Learning: Using String Variables
- •7.1.5A String as a Member Variable of a Class
- •7.1.6Practical Learning: Using Strings as Fields
- •7.2Inheritance
- •7.2.1 Introduction
- •7.2.2Practical Learning: Introducing Inheritance
- •7.2.3Inheriting From a Class
- •Int Bedrooms;
- •Int YearBuilt;
- •Int Bedrooms;
- •Int YearBuilt;
- •Int Condition;
- •7.2.4Practical Learning: Inheriting From a Class
- •7.2.5The protected Access Level
- •Int Bedrooms;
- •Int YearBuilt;
- •7.2.6Namespaces and Inheritance
- •7.3The Object Class
- •7.3.1 Introduction
- •7.3.2An Object as a Handle
- •Int main()
- •Int main()
- •7.3.3Inheriting from the Object Class
- •7.3.4Practical Learning: Inheriting From the Object Class
- •8.Data Input/Output, Reading, and Formatting
- •8.1 Displaying Data
- •8.1.1 Introduction
- •8.1.2General Display With cout, Write(), and WriteLine()
- •Int main()
- •Int main()
- •8.1.3Data Display With puts()
- •Int main()
- •Int main()
- •Int main()
- •Int main()
- •Int main()
- •Int main()
- •8.2.2Filling the Empty Space
- •Int main()
- •Int main()
- •8.2.3The dec, hex, and oct Operators
- •Int main()
- •Int main()
- •8.2.4The uppercase Attribute
- •8.2.5Setting the I/o Flag
- •Int main()
- •Int main()
- •Int main()
- •Int main()
- •8.2.7C How to Display Data
- •Int main()
- •Int main()
- •8.3Data Input
- •8.3.1Using cin
- •Int main()
- •Int Natural;
- •8.3.2C How to Input Data
- •8.4Accessories
- •8.4.1Exiting a Program
- •Int main()
- •8.4.2Aborting a Program
- •8.4.3Terminating a Program
- •8.4.4Clearing the Screen
- •Int NumberOfBedrooms;
- •Int YearBuilt;
- •Int main()
- •8.5.1 Introduction
- •8.5.2Practical Learning: Introducing Data Reading
- •Int Bedrooms;
- •Int YearBuilt;
- •Int Condition;
- •Int main()
- •8.5.3String Value Request
- •Int main()
- •8.5.4Character and Number Request
- •Int main()
- •Int Number;
- •8.5.5Practical Learning: Requesting Data
- •8.6Formatting Data Display
- •8.6.1 Introduction
- •Int main()
- •8.6.2Conversion To String
- •Int main()
- •8.6.3Number Formatting
- •Int main()
- •8.6.4Line Formatting
- •Int main()
- •8.6.5Practical Learning: Formatting Data
- •Int main()
- •9. Introduction to Functions
- •9.1 Functions
- •9.1.1 Definition
- •9.1.2Fundamentals of Creating a Function
- •Void Introduction() { Console::WriteLine(l"The Wonderful World of
- •Void Introduction()
- •Int main()
- •9.1.3Calling a Function
- •Void Introduction()
- •Int main()
- •Introduction();
- •Int main()
- •Void IdentifyHouse();
- •Void IdentifyHouse()
- •9.1.4Practical Learning: Introducing Functions
- •Void CreateAndShowProperty()
- •Int condition;
- •9.1.5Inline Functions
- •9.2Techniques of Returning a Value
- •9.2.1 Returning a Primitive Type
- •Int main()
- •9.2.2Practical Learning: Returning a Primitive Type
- •Int GetPropertyCondition()
- •Int condition;
- •Void CreateAndShowProperty()
- •Int condition;
- •Int main()
- •9.2.3Returning a Native Reference
- •Int main()
- •9.2.4Returning a Tracking Reference
- •Int main()
- •9.2.5Returning a Pointer
- •Int main()
- •9.2.6Returning a Handle
- •9.2.7Practical Learning: Returning a Handle
- •Void CreateAndShowProperty()
- •Int main()
- •9.3Introduction to Functions Parameters
- •9.3.1 Overview of Parameters
- •Int main()
- •9.3.2Arguments to a Function
- •Void SetGender(__wchar_t a);
- •Void CalculateRateAmount(double price, double rate)
- •9.3.3Practical Learning: Introducing Functions
- •Void ShowProperty(long propNbr, int cond, Byte levels,
- •9.3.4Static Variables
- •Void Starter(int y)
- •Int main()
- •Void Starter(int y)
- •Int main()
- •Void Starter(int y)
- •Int main()
- •10.Details on Passing Arguments
- •10.1 Common Techniques of Using Parameters
- •10.1.1 Function Overloading
- •Int main()
- •10.1.2Default Arguments
- •Int main()
- •Int main()
- •Int main()
- •Int main()
- •Int main()
- •10.1.3Constant Arguments
- •Int main()
- •10.2Passing Arguments by Reference
- •10.2.1 Passing by Native Reference
- •Void Area(double &Side); // The argument is passed by reference
- •Void Area(double &);
- •10.2.2Passing by Constant Reference
- •Void DisplayResult(const double OrigPrice, const double DiscAmt,
- •10.2.3Passing by Tracking Reference
- •10.3Passing a Pointer as Argument
- •10.3.1 Introduction
- •Int main()
- •Int main()
- •Int main()
- •10.3.2Constant Pointers as Arguments
- •Int main()
- •10.3.3Passing a Pointer to a Pointer
- •10.3.4Passing an Argument as a Reference to a Pointer
- •Int main()
- •10.3.5Passing an Argument as a Handle
- •Int main()
- •11.Classes and Functions
- •11.1 Returning a Class Type
- •11.1.1 Returning a Tracking Reference
- •Int Doors;
- •Int Year;
- •Int main()
- •11.1.2Practical Learning: Introducing Data Reading
- •Int Bedrooms;
- •Int YearBuilt;
- •Int Condition;
- •Int main()
- •11.1.3Returning a Handle
- •11.1.4Practical Learning: Returning a Handle
- •Int main()
- •11.2Passing a Class Type
- •11.2.1 Passing a Tracking Reference
- •Void DescribeProperty(cHouse % home);
- •Void Show(cCar % car)
- •11.2.2Passing a Handle
- •11.2.3Practical Learning: Passing a Handle
- •Int main()
- •11.2.4The Effect of Passing a Class as a Tracking Reference or as a Handle
- •Int Doors;
- •Int Year;
- •Int main()
- •11.2.5Passing a Handle as a Reference
- •Int Doors;
- •Int Year;
- •Int main()
- •Int Doors;
- •Int Year;
- •Int main()
- •11.3Using the String Class
- •11.3.1 Returning a String
- •Int main()
- •11.3.2Passing a String
- •Int main()
- •11.4Introduction to the Methods of a Class
- •11.4.1 Methods Fundamentals
- •11.4.2Practical Learning: Introducing Methods
- •Int main()
- •11.4.3Method Local Definition
- •Int Doors;
- •Int Year;
- •Void Build()
- •Int main()
- •11.4.4Practical Learning: Implementing a Method Locally
- •Void CreateStoreItem()
- •11.4.5Method Global Definition
- •Int Doors;
- •Int Year;
- •Void Build()
- •Void Show();
- •Void cCar::Show()
- •Int main()
- •11.4.6Practical Learning: Implementing Methods Globally
- •Void CreateStoreItem();
- •Void ItemDescription();
- •Void cStoreItem::CreateStoreItem()
- •Void cStoreItem::ItemDescription()
- •Int main()
- •Item Number: 624406
- •Item Number: 624406
- •11.4.7Inline Methods
- •11.5Class and Self Return
- •11.5.1 Introduction
- •Int NumberOfBedrooms;
- •Int YearBuilt;
- •11.5.2This Pointer
- •Void cHouse::Show()
- •11.5.3Practical Learning: Using the this Pointer
- •Void cStoreItem::CreateStoreItem()
- •0 If no discount): ");
- •Void cStoreItem::ItemDescription()
- •12.1.3Constant Arguments
- •Int main()
- •12.1.4Practical Learning: Passing Constant Arguments
- •0 If no discount): ");
- •Item Number: 204066
- •Item Number: 204066
- •12.1.5Private Methods
- •Void Show();
- •Void cBox::Show()
- •Int main()
- •12.1.6Protected Methods
- •12.2Static Members of a Class
- •12.2.1 Static Member Variables
- •Void cCar::Show()
- •Int main()
- •12.2.2Static Methods
- •Int Doors;
- •Int Year;
- •Void Build();
- •Int Doors;
- •Int Year;
- •Int main()
- •Int Doors;
- •Int Year;
- •Int main()
- •12.3Classes and Constants
- •12.3.1 Static Constants
- •Inside a ref class or value type
- •12.3.2Literal Constants
- •12.4Class Nesting
- •12.4.1 Introduction
- •12.4.2Implementing Methods of a Nested Class
- •13. Class Construction and Destruction
- •13.1 Class Construction
- •13.1.1 Method Initializer
- •Int Type;
- •Int Color;
- •Int main()
- •Int Type;
- •Int Color;
- •Void Initializer(int type, int color, __wchar_t arrange,
- •Void cFlower::Initializer(int tp, int clr,
- •13.1.2Practical Learning: Introducing Constructors
- •Int main()
- •13.1.3Default Constructor
- •Int Type;
- •Int Color;
- •Int Type;
- •Int Color;
- •Int main()
- •Int main()
- •Int Type;
- •Int Color;
- •13.1.4Practical Learning: Using the Default Constructor
- •13.1.5The Constructor Initializer
- •Int main()
- •13.1.6Practical Learning: Initializing Using the Default Constructor
- •Int main()
- •Item Number: 0
- •13.1.7Constructor Overloading
- •Int main()
- •13.1.8Practical Learning: Overloading the Constructor
- •Inline long cStoreItem::GetItemNumber()
- •Inline void cStoreItem::SetItemNumber(const long number)
- •13.1.9Techniques of Initializing With a Constructor
- •Int main()
- •13.1.10Practical Learning: Initializing With the Constructors
- •13.2The Copy Constructor
- •13.2.1 Copying an Object
- •Int main()
- •13.2.2Using a Copy Constructor
- •13.3Destructors
- •13.3.1Introduction
- •13.3.2Practical Learning: Creating a Destructor
- •13.3.3Object Destruction in the Native Heap
- •13.3.4Object Destruction and the Managed Heap
- •14. The Properties of a Class
- •14.1Properties Fundamentals
- •14.1.1Introduction
- •14.1.2Practical Learning: Introducing the Properties of a Class
- •Int main()
- •14.1.3Reference Methods
- •Int main()
- •Int main()
- •14.1.4A Property
- •14.2Types of Properties
- •14.2.1 Simple Properties
- •Void ShowCharacteristics(cRectangle %recto)
- •Int main()
- •Int main()
- •14.2.2Practical Learning: Creating Simple Properties
- •Int main()
- •Item Number: 0
- •Item Number: 513497
- •14.2.3Read-Only Properties
- •Int main()
- •14.2.4Practical Learning: Using Read-Only Properties of a Class
- •Int main()
- •14.2.5Write-Only Properties
- •Void set(double h) { }
- •Int main()
- •14.2.6Read/Write Properties
- •14.2.7Practical Learning: Using Read/Write Properties of a Class
- •Int main()
- •Information");
- •Item Number: 666802
- •Item Number: 666802
- •14.3Other Techniques of Implementing Properties
- •14.3.1 Static Properties
- •Int main()
- •Int main()
- •Int main()
- •Int main()
- •15.1.2Declaring a Pointer to Function
- •Int main()
- •Void (*SomethingToSay)(void);
- •Void MovieQuote()
- •Void MovieQuote()
- •Int main()
- •Void (*SomethingToSay)();
- •15.1.3A Function Pointer that Returns a Value
- •Int Addition()
- •Int main()
- •Int (*SomeNumber)();
- •15.1.4A Function Pointer With Arguments
- •15.1.5Type-Defining a Function Pointer
- •Int Addition(int a, int b)
- •Int main()
- •15.1.6A Pointer to a Function as Argument
- •Int main()
- •15.2Classes and Pointers to Functions
- •15.2.1A Pointer to Function as a Member Variable
- •Int main()
- •Int main()
- •15.3Delegates
- •15.3.1 Introduction
- •15.3.2Practical Learning: Introducing Delegates
- •Void Show();
- •Void cFlower::Show()
- •Int main()
- •15.3.3Delegate Declaration
- •15.3.4Practical Learning: Creating a Delegate
- •Int main()
- •15.3.5Techniques of Using a Delegate
- •Int main()
- •Int main()
- •Int main()
- •Void ShowResult()
- •Int main()
- •15.3.6Practical Learning: Creating a Delegate
- •Int main()
- •15.3.7Delegates Compositions
- •15.3.8A Delegate With One of More Arguments
- •Void ShowResult()
- •Int main()
- •15.3.9Practical Learning: Using an Argumentative Delegate
- •Void Show(const int qty);
- •Void cFlower::Show(const int qty)
- •Int main()
- •15.3.10A Delegate Passed as Argument
- •Void CircleCharacteristics()
- •Int main()
- •16. Introduction to Conditions
- •16.1Boolean Variables
- •16.1.1 Introduction
- •16.1.2Practical Learning: Introducing Conditions
- •Int get() { return _tp; }
- •Int get() { return _clr; }
- •Int get() { return _qty; }
- •Int type, color, qty;
- •16.1.3Declaring a Boolean Variable
- •Int main()
- •Int main()
- •Int main()
- •Int main()
- •Int main()
- •16.1.4Retrieving the Value of a Boolean Variable
- •Int main()
- •If Yes, enter True. Otherwise enter False: true
- •16.1.5Creating a Boolean Member Variable
- •16.1.6 Boolean Arguments
- •16.1.7A Boolean Property
- •16.1.8 Practical Learning: Creating a Boolean Property
- •16.2Enumerations
- •16.2.1 Introduction
- •Int main()
- •Int main()
- •16.2.2 Indexing the Members of an Enumeration
- •Int main()
- •Int main()
- •Int main()
- •Int main()
- •16.2.3Declaring an Enumeration Variable
- •16.2.4Global Enumerations
- •16.2.5Enumerations and Assemblies
- •16.3Enumerations and Classes
- •16.3.1 An Enumeration as a Member Variable
- •16.3.2An Enumeration as a Class
- •16.3.4Practical Learning: Creating Enumerations
- •17. Conditional Operators
- •18. Conditional Statements
- •19. Counting and Looping
- •20. Strings
- •21. Techniques on Using Inheritance
- •22. Variable Scope and Casting
- •23. Templates
- •24. Generics
- •25.Введение в массивы
- •25.1 Описание
- •25.1.1 Определение
- •25.1.2Создание массива
- •Int main()
- •Int Numbers[5];
- •25.1.3Initializing an Array
- •Int main()
- •Int main()
- •25.1.4 Type Defining an Array
- •Int main()
- •25.2Arrays and Memory Management
- •25.2.1 Creating a Dynamic Array
- •Int main()
- •Int main()
- •25.2.2 Cleaning After an Array
- •Int main()
- •25.3Managed Arrays
- •25.3.1 Introduction
- •Int main()
- •Int main()
- •25.3.2Practical Learning: Introducing Arrays
- •Int main()
- •25.3.3An Array of Handles
- •Int main()
- •Int main()
- •Int main()
- •Int main()
- •Int main()
- •25.3.4Practical Learning: Using an Array of Handles
- •Int main()
- •25.4Arrays and Functions
- •25.4.1 Returning an Array
- •Int main()
- •25.4.2Practical Learning: Returning Arrays
- •25.4.3Passing an Array as Argument
- •25.4.4Practical Learning: Passing an Array as Argument
- •26. Multi-Dimensional Arrays
- •26.1 Single and Two-Dimensional Arrays
- •26.1.1 Introduction
- •26.1.2Practical Learning: Introducing Multi-Dimensional Arrays
- •26.1.4Multi-Dimensional Arrays
- •26.2Introduction to Jagged Arrays
- •26.2.1 Introduction
- •26.2.2 Creating a Jagged Array
- •26.2.3 Initializing a Jagged Array
- •26.3Jagged Arrays and Functions
- •26.3.1Returning a Jagged Array
- •26.3.2Passing a Jagged Array as Argument
- •26.4Multi-Dimensional Jagged Arrays
- •26.4.1Two-Dimensional Jagged Arrays
- •26.4.2Multi-Dimensional Jagged Arrays
- •27.Arrays and Classes
- •27.1The Array Class
- •27.1.1 Introduction
- •27.1.2 The Length of an Array
- •Int main()
- •28.Introduction to File Processing
- •29.Details on File Processing
- •30.Files Operations
- •31.Serialization
- •32.Introduction to Indexed Properties
- •33.Classes and Indexed Properties
- •34.Введение в коллекции
- •34.1Коллекции на основе массива
- •34.1.1Вступление
- •34.1.2Объявление коллекции
- •Int main()
- •34.1.3 Количество элементов в коллекции
- •34.2Операции над коллекцией, основанной на массиве
- •34.2.1 Добавление элемента
- •Int size;
- •Int get() { return size; }
- •Int main()
- •34.2.2 Извлечение элемента из коллекции
- •Int size;
- •Int get() { return size; }
- •Int main()
- •34.2.3 Вставка элемента в коллекцию
- •Int size;
- •Int get() { return size; }
- •1. Список не заполнен до конца
- •2. Указанная позиция находится в допустимом диапазоне
- •Int main()
- •34.2.4 Удаление элемента из коллекции
- •Int size;
- •Int get() { return size; }
- •Int main()
- •34.3Коллекция элементов (заказ букета цветов)
- •34.3.1 Вступление
- •34.3.2Practical Learning: Introducing Collections
- •34.3.3 Implementing a Collection
- •34.3.4 Practical Learning: Creating a cCollection Class
- •34.3.5The Beginning of a Collection
- •34.3.6 Linking the Items of a Collection
- •34.3.7 Practical Learning: Creating a List's Monitor
- •34.4 Коллекции на основе списка (Operations on a Collection)
- •34.4.1 Adding an Item
- •34.4.2 Practical Learning: Adding Items to a Collection
- •34.4.3Retrieving an Item
- •34.4.4 Practical Learning: Retrieving the Items of a Collection
- •34.4.5 Removing an Item
- •34.4.6 Practical Learning: Retrieving the Items of a Collection
- •34.4.7 Locating an Item
- •35.Основы коллекций платформы .Net (Fundamentals of .Net Support For Collections)
- •35.1 Перечисление элементов коллекции (Enumerating the Members of a Collection)
- •35.1.1 Введение в коллекции System
- •35.1.2Практический пример
- •Int Mileage;
- •Int items;
- •Int get() { return items; }
- •Virtual bool Delete() override;
- •Items--;
- •35.1.3Introduction to the iEnumerator Interface
- •35.1.4 Упражнение
- •35.1.5 Текущий элемент перечисления
- •35.1.6Упражнение
- •Int curPosition;
- •35.1.7Сброс метки текущего элемента
- •Void Reset();
- •Virtual void Reset();
- •Void cEnumerator::Reset()
- •35.1.8 Упражнение
- •Int curPosition;
- •Virtual void Reset();
- •Void cCarIdentifier::Reset()
- •35.1.9Перемещение к следующему элементу в iEnumerator
- •Virtual void Reset();
- •Virtual bool MoveNext();
- •Void cEnumerator::Reset()
- •35.1.10Упражнение
- •Int curPosition;
- •Virtual void Reset();
- •Virtual bool MoveNext();
- •Void cCarIdentifier::Reset()
- •35.2Перечислимая коллекция (An Enumerable Collection)
- •35.2.1 Вступление
- •35.2.2 Получение Enumerator (Getting the Enumerator)
- •35.2.3Упражнение
- •36.Встроенные интерфейсы коллекций
- •36.1 Обзор интерфейсов коллекций
- •36.1.1 Вступление
- •36.1.2Choosing a Class or an Interface
- •36.2Интерфейс iCollection
- •36.2.1 Вступление
- •36.2.2Реализация iCollection
- •Int nbrOfStudents;
- •Virtual property int Count
- •Int get() { return nbrOfStudents; }
- •Int nbrOfItems;
- •Virtual property int Count
- •Int get() { return nbrOfItems; }
- •Int nbrOfItems;
- •Int nbrOfItems;
- •Virtual property bool IsSynchronized
- •Int nbrOfItems;
- •36.3Интерфейс iList
- •36.3.1Вступление
- •36.3.2Упражнение
- •Int main()
- •36.3.3Implementing iList
- •36.3.4 Упражнение
- •36.4Размер коллекции
- •36.4.1 Коллекция фиксированного размера
- •Int items;
- •Virtual property bool IsFixedSize
- •36.4.2 Упражнение
- •Int counter;
- •Virtual property bool IsFixedSize
- •36.4.3Коллекция только для чтения
- •36.4.4Упражнение
- •Int counter;
- •Virtual void RemoveAt(int index);
- •Virtual void Clear(void);
- •36.5Наполнение коллекции
- •36.5.1 Добавление элементов
- •Int items;
- •36.5.2Упражнение
- •Int main()
- •36.5.3Вставка элемента
- •36.5.4Упражнение
- •Int main()
- •36.6Размещение элемента в коллекции
- •36.6.1 Значение по умолчанию в коллекции
- •Int items;
- •36.6.2Упражнение
- •Int counter;
- •Int main()
- •36.6.3Проверка существования элемента в коллекции
- •Int items;
- •36.6.4 Упражнение: проверка наличия элемента в коллекции
- •Int main()
- •36.6.5Получение индекса элемента
- •Int items;
- •36.6.6Упражнение: получение индекса элемента
- •Int main()
- •36.7Удаление элементов коллекции
- •36.7.1 Удаление элемента по его индексу
- •37.Встроенные классы коллекций
- •37.1 Класс ArrayList
- •37.1.1 Вступление
- •37.1.2 Емкость списка (The Capacity of a List)
- •37.1.3Список только для чтения
- •37.1.4Добавление элементов
- •37.1.5 Число элементов в списке
- •37.1.6 Получение элементов списка
- •37.1.7Доступ к элементу списка
- •37.1.8Удаление элемента
- •37.2Хеш-таблицы
- •37.2.1Вступление
- •37.2.2Создание хеш-таблицы
- •37.2.3Доступ к элементам хеш-таблицы
- •If (!diGcs.Exists)
- •If (!File.Exists(strFilename))
- •If (!File.Exists(strFilename))
- •If (File.Exists(strFilename))
- •If (File.Exists(strFilename))
- •If (File.Exists(strFilename))
- •37.2.4Доступ к элементу хеш-таблицы
- •37.2.5Удаление элементов хеш-таблицы
- •37.3Стек
- •37.3.1 Вступление
- •37.3.2Создание стека
- •37.3.3Добавление элементов в стек
- •37.3.4Доступ к элементам стека
- •37.3.5Удаление элементов из стека
- •37.4Очередь
- •37.4.1Вступление
- •37.4.2Создание очереди
- •37.4.3Построение очереди (Building a Queue)
- •37.4.4Получение элементов очереди
- •37.4.5Удаление элементов из очереди
3.7.5Initializing a Double-Precision Variable
You may have found out that when you declare and initialize a float or Single variable, the compiler generates a warning. Consider the following example:
using namespace System;
Int main()
{
float Fraction = 12.35;
Console::WriteLine(Fraction);
Console::WriteLine();
return 0;
}
When compiled, you would get the following warning:
.\Exercise.cpp(5) : warning C4305: 'initializing' : truncation from 'double' to 'float'
Although the program would compile fine. By default, when the compiler sees a value such as 12.35, for the sake of precision, it tends to store it as a double value. If you really want the variable to be treated as a float or Single, add the f or F to its right. Here is an example:
using namespace System;
Int main()
{
float Fraction = 12.35f;
Console::WriteLine(Fraction);
Console::WriteLine();
return 0;
}
This time, the compiler will not generate a warning. Remember that you can use f (lowercase) or F (uppercase).
3.8Variable Reference
3.8.1 The typedef Type Definition
The data types we have used so far may have names we are not familiar with. C++ allows you to customize the name of a data type to a name you are more familiar with. You would not (and are not allowed to) create a new data type, you would only "redefine" the name of an existing data type.
To customize the name of a data type, you can use the typedef keyword. The formula used is:
typedef KnownDataType NewName;
The typedef keyword is required to let the compiler know that you are creating a new data type. The data type must be one that exists already, such as those we have reviewed so far. It could be an int, an unsigned int, an Int32, a char, a double, etc. An example of using a typedef is:
using namespace System;
Int main()
{
typedef unsigned int PositiveNumber;
return 0;
}
In this case, PositiveNumber is just a new name for an unsigned int. It can be used as a new data type exactly as if you were using an unsigned int. Here are examples:
using namespace System;
Int main()
{
typedef unsigned int PositiveNumber;
typedef double Salary;
PositiveNumber Gender = 1;
Salary WeeklySalary = 1450.88;
Console::Write("Gender: ");
Console::WriteLine(Gender);
Console::Write("Salary: ");
Console::WriteLine(WeeklySalary);
return 0;
}
This would produce:
Gender: 1
Salary: 1450.88
3.9Native References
A reference is a variable that is a duplicate of an existing variable. It provides a technique of creating more than one name to designate the same variable. The syntax of creating or declaring a reference is:
DataType &ReferenceName = VariableName;
To declare a reference, type the variable’s name preceded by the same type as the variable it is referring to. Between the data type and the reference name, type the ampersand operator “&”. To specify what variable the reference is addressed to, use the assignment operator “=” followed by the name of the variable. The referred to variable must exist already. You cannot declare a reference as:
Int &Mine;
The compiler wants to know what variable you are referring to. Here is an example:
using namespace System;
