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

 

شكرا  جزيلا

 

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.

 

Good afternoon,


I can't understand this section:

//--- this block will not be executed if execute==false
   if(execute)
     {
      CObjectB objB;
     }
//--- this block will be executed if execute==false
   if(!execute)
     {
      CObjectC objC;
     }

At the beginning of the code it is set that execute = false. The words: execute equals false.

The first IF: if execute is true, the block should be executed. But in the comment it says that it will NOT execute if it is TRUE and will move on to the next one.

Second IF: if execute is FALSE, the block will execute. But again the comment says that the block will EXECUTE if True.

I assumed that ! - is a negation symbol.

Where is the error in my reasoning?

 
kashi_ann:

Good afternoon,


I can't figure out this plot:

At the beginning of the code it is set that execute = false. The words: execute equals false.

The first IF: if execute is true, the block should be executed. But the comment says that it will NOT execute if it is True and will move on to the next one.

Second IF: if execute is FALSE, the block will execute. But again the comment says that the block will EXECUTE if True.

I assumed that ! - is a negation symbol.

Where is the error in my reasoning?

I've highlighted your erroneous judgement. For reference: 'false' is False, 'true' is True.

And to make it clearer, I've added comments:

//--- this block will not be executed if execute==false
//--- this block will be executed if execute==true
   if(execute)
     {
      CObjectB objB;
     }
//--- this block will be executed if execute==false
//--- this block will not be executed if execute==true
   if(!execute)
     {
      CObjectC objC;
     }
 
Vladimir Karputov:

Your erroneous judgement is highlighted in colour. For reference: 'false' is False, 'true' is True.

And to make it clearer I added comments:

So... the following entries...

if(execute = true) и if(execute) - тожественны?
if(execute = false) и if(!execute) - тоже?

right?

 
kashi_ann:

Okay. we get the following notes.

right?

It's the basics.

 
Artyom Trishkin:

It's the basics.

Thank you) The basics are the most important thing)

And thank you for not being lazy to answer)
 
kashi_ann:

Okay. we get the following notes.

right?

It just so happens that yes, but you clearly wanted to use ==, not =.

 
Andrey Khatimlianskii:

So coincidentally yes, but you clearly wanted to use == rather than =.

Nah))))) the meaning and difference between = and == I have yet to figure out) I'm at the beginning of my journey).

 
kashi_ann:

Nah)))) the meaning and difference between = and == I have yet to figure out) I'm at the very beginning of my journey)).

"=" is an assignment operator and "==" is a comparison operator.