PLO. Application issues - page 9

 

But you don't really need to do this....

You should use virtualization of functions

P.S. And you can't build a normal program with implicit type conversion. It's just a variant... like the GoTo.... operator

Документация по MQL5: Основы языка / Типы данных / Приведение типов
Документация по MQL5: Основы языка / Типы данных / Приведение типов
  • www.mql5.com
Основы языка / Типы данных / Приведение типов - Документация по MQL5
 
AlexSTAL:
2) The main thing is to delete it before the program ends... But if you have this pointer created in a function, you need to take care of saving it in a global location...


That's what I thought too, the array seems to be global, but there's a leak. Or is it not just the array that needs to be there, but something else as well?

 
You really make me laugh ))))
 
Interesting:

That's what I thought too, the array seems to be global, but there's a leak. Or is it not just the array, but something else too?

Well you may have a leak somewhere else...

I have hundreds of classes created this way and never had any leaks anywhere....

You try a simple example....

 
TheXpert:
You really make me laugh ))))
Sometimes it's good for you... nerve-racking ....
 
AlexSTAL:

Well you might have a leak somewhere else...

I have hundreds of classes created this way and never had any leaks anywhere....

Try a simple example....

I think I got rid of it, by putting this code into EA uninstall block (no problems so far)

  for (int i=0; i<ArraySize(ArrShapes);i++)  
  {
  ArrShapes[i].Free(ArrShapes[i]);
  }
 

It ended up like this, very incomprehensible.

It's a monster in a word... :)

Files:
Forum-2.mq5  11 kb
 

Anyway, as a result of the discussion on the problemhttps://www.mql5.com/ru/forum/3566/page6#comment_58280 sent an application to the SR.

 
Yedelkin:

In general, following a discussion on the problemhttps://www.mql5.com/ru/forum/3566/page6#comment_58280 sent an application to the SR.

1. I don't know, I don't know.

I think the developers will not go to the trouble of sacrificing functionality for the sake of security (it's the right thing to do in one sense).

Perhaps the way proposed by Aleksander(AlexSTAL) would have solved the problem (let's not take into account its somewhat troublesome nature).

But by doing so, we'll at best get access to events and methods of descendants (in which case properties, variables and such things not declared in the ancestor are unlikely to be used).

However, we will most likely have to experiment.


2. on the basis of what we have now, we can do something else, I see 2 options:

а. Use specialized arrays which contain objects of one class only (descendants of a certain type);

In this case you can get access to any properties, methods and events of objects in an array (because they are homogeneous);

б. If it's necessary to work with an array of objects of different types, which are descendants of one base class, you'll have to create additional arrays to store each type of descendants.

Thus, in main array we'll get access only to common for all objects functionality (if not AUTOGEN and QUALDA), and in specialized arrays access to full functionality of each type of descendants.

As I understand it, we will get something like a database consisting of several tables, with one-to-many and many-to-one connection methods. In this case, however, there will be a question of proper synchronization of the whole affair. Additionally, we will have to decide on the basis of which all arrays (tables) of the improvised database will be linked.

Binding can be based on some unique identifiers, for example, based on pointers or specialized handles (like those used in turkeys).

PS

By the way, I think the idea with handles is good enough (even if you take pointers as a base of all work with objects). Handles should allow to distinguish the unique object from the similar ones or from the whole list of objects.

 
TheXpert:
You really make me laugh ))))
Sometimes I'm really freaking myself out, it's good that sometimes. :)
Reason: