Discussion of article "The Order of Object Creation and Destruction in MQL5"

 

New article The Order of Object Creation and Destruction in MQL5 is published:

Every object, whether it is a custom object, a dynamic array or an array of objects, is created and deleted in MQL5-program in its particular way. Often, some objects are part of other objects, and the order of object deleting at deinitialization becomes especially important. This article provides some examples that cover the mechanisms of working with objects.

MQL5-programs are written in concepts of Object Oriented Programming (OOP), and that not only opens up new possibilities for creating custom libraries, but also allows you to use complete and tested classes of other developers. In the Standard Library, that is included into the MetaTrader 5 Client Terminal, there are hundreds of classes that contain thousands of methods.

To take full advantages of OOP we must clarify some details about creating and deleting objects in MQL5 programs. Creating and Deleting Objects is briefly described in Documentation, and this article will illustrate this topic in examples.

Author: MetaQuotes

 

شكرا  جزيلا

 

m_array[] got copied from GetPointer(arrray[i]) function,  so they become POINTER_AUTOMATIC type.

We don't need line 54:

 if(CheckPointer(m_array[i])==POINTER_DYNAMIC) delete(m_array[i]);

because MQL5 deletes POINTER_AUTOMATIC for you.

Reason: