PLO. Application issues - page 16

 
Yedelkin:

Are the questions really heavy/incorrect?

For a long time I used the first way ("by reference"), but I really like the idea of descriptors. I just don't know if it's worth rewriting all the classes for.

The first way would work faster. Access via "descriptor" is longer.
 
mql5:
The first method will work faster. Access via the 'descriptor' takes longer.
Thank you, that's very helpful.
 

A clue,

If a parent class has 15 methods, but the child class has one method of its own and uses only three methods inherited from the parent class, how will memory be allocated for the child class: based on the need to allocate memory for 16 methods, or based on only 4 actually used methods?

Документация по MQL5: Основы языка / Переменные / Создание и уничтожение объектов
Документация по MQL5: Основы языка / Переменные / Создание и уничтожение объектов
  • www.mql5.com
Основы языка / Переменные / Создание и уничтожение объектов - Документация по MQL5
 
Yedelkin:

Can you give me a hint?

You're filling your head with the wrong things.)
 
Yedelkin:

A clue,

If a parent class has 15 methods, but the child class has one method of its own and uses only three methods inherited from the parent class, how will memory be allocated for the child class: based on the need to allocate memory for 16 methods, or based on only 4 actually used methods?

The object's memory is allocated for data, not methods. All methods (i.e. functions) are stored in a single instance in the executable code
 
stringo:
The memory of an object is not allocated to methods, but to data. All methods (i.e. functions) are stored in a single instance in the executable code
I think I've got it. If the same method from the parent class is used in 10 different child classes, it will still be stored in a single instance in the executable code.
 

The search doesn't work. I may be repeating myself, but the question is: can a class object destroy itself? I.e. first we get a reference of the object to itself in the class object using the reserved word this, then we apply the delete operator to the corresponding object descriptor (pointer).

Something like:

pointer=GetPointer(this);
delete pointer;

Or is it better/preferable to delete an object "externally" rather than "internally"?

 
GetPointer gives a pointer of a non-deletable type. The object cannot delete itself. And that's right :)
 
Yedelkin:

........: Can a class object destroy itself? That is, we first obtain a reference to the object itself in the class object using the reserved word this, then we apply the delete operator to the corresponding object descriptor (pointer).

Suicidal tendencies are a sure sign of considering the situation in too narrow a context.)

I have a counter question: where are you going to call all this stuff from? Write a more practical example, so that you can see the thread of execution in your program. How will you address the object?

Let me explain. If the object is static (global level) or automatic (in the stack), we don't need to address it. The executing system will eliminate it automatically when it's needed.

But if the object is dynamic, it means that it has an external reference which should be zeroed when deleting.

There are no other options.

 
MetaDriver:

Suicidal tendencies are a sure sign of viewing the situation in too narrow a context. :)

...
Can you teach me how to say foul language like that? :о)