
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
This is not the first time I've caught myself thinking that in MQL it's better to use OOP only in case of urgent need and only in a certain code section.
I read somewhere and an example appeared on the forum with such a construction
can someone do a simple example with this ?
I'm interested in what this delete &this deletes;
I read somewhere and an example appeared on the forum with such a construction
can someone do a simple example with this ?
I am interested in what this delete &this deletes;
It deletes itself)))
It removes itself)))
that makes sense
but I suspect that the whole point is to use it with static methods
need to test it, really don't know how, that's why I asked
UPD: googled this topic yesterday, lots of mentions of private destructor, also need to think what it can do
1) but I suspect the whole point of "delete &this;" - use with static methods
2) yesterday googled this topic, many references to private destructor, also need to think what it can provide
1) From static methods, access to this is forbidden.
Where's "delete &this;" - https://stackoverflow.com/questions/447379/what-is-the-use-of-delete-this
2) The private destructor disallows creating an object on the stack, but an object can still be created through the new operator, this time in the heap:
Here is another use of delete &this.
1) From static methods, access to this is forbidden.
Where do "delete &this;" - https://stackoverflow.com/questions/447379/what-is-the-use-of-delete-this
2) A private destructor forbids creating an object on the stack, but an object can still be created through the new operator, this time in the heap:
Here is another use of delete &this.
You can always do something with something. But what is the point?
You should invent a name, declare it as a design pattern... and that's it. It's so cool to write a bunch of code instead of just "delete something".
I read somewhere and an example appeared on the forum with such a construction
can someone do a simple example with this ?
i'm interested in what this delete &this deletes;
this is a pointer to the current object.
Usually the delete this construct is used where an object is created by new, but the responsibility for deleting is on the object itself. In this case, when the object decides it is no longer needed, it calls the deinitialisation function, in which it deletes itself like this.
In my opinion, this is an extremely dangerous practice, acceptable only in case of smartpoints which will count references to the object themselves and then, when number of references becomes zero, they can delete themselves. But even in this case, it seems to me, there is room for hard-to-find memory leakage errors.
In my opinion, the responsibility for deletion should lie with the same object that created it. It can use the object factory pattern when creating it, but deletion should still be the responsibility of the object that created the new object.