![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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
Lately I've started to see some kind of "rubbish collection" in the functions of various compilers. What is it?
Here it will depend on the language, in Sharp, as I understand it is impossible.
It is, all that can be done is to assign an unused object to NULL, there are manuals on Microsoft site how to force to call the rubbish collector, but it seems that I read on hubra that not the fact that the collector will be launched in this call as expected
that is, in Sharp they have taken most of the memory management away from the programmer - everything is at the mercy of the OS and the compiler
It is, all you can do is assign an unused object to NULL, there are manuals on Microsoft site to force the rubbish collector, but it seems that I read on hubra that not the fact that the collector will be launched in this call as expected
that is, in Sharp they have taken most of the memory management away from the programmer - everything is at the mercy of the OS and the compiler
There you go. I'm currently writing my first Sharp textbook and I'm creeped out by absence of delete in code after new in method))).
instead of delete MyObj; write MyObj = null; - this will work
and then use ?? - it was a bit awkward at first, then it works automatically
but it's not the biggest difference from C++, in C# all objects are references and if you set MyObj_1=MyObj_2; you don't get a copy, you get a pointer... I'm about to confuse you, here's a quick tutorial, I'm just looking over it in case I've forgotten anything
https://metanit.com/sharp/tutorial/2.16.php
I think I'm beginning to understand the necessity and usefulness of OOP, but I'm having trouble implementing it.
I have a class that is to be used with three different sets of variables. But it performs one task. In simple terms, we can insert 3 constructors, declare 3 variables and refer to them. But as I see it, it is not quite correct. On top of that, there is one variable of the string type in two variants but it is different in name and is used in different parts of the code. Of course, you may change the sequence of variables but I think this is not quite correct either.
I read the documentation about the new operator but do not understand how it may help. I do not see the difference between three different object variables and three pointers to the same objects. Perhaps it's profitable when you create a pointer once, use this object and delete it when it is not needed. But if you need the object regularly, it's absolutely silly to create a pointer to it each time and delete it.
So, please give me a hand. I've read some explanations of OOP in C++, but they are described there in a worse way than in the documentation on mql5. Please do not ask the impatient ones to join me, I will ask too many questions. I'm not interested in ready-made code without explanations either, I want to understand it, and not to stupidly repeat "Do with us, do as we do...".
I think I'm beginning to understand the necessity and usefulness of OOP, but I'm having trouble implementing it.
I have a class that is to be used with three different sets of variables. But it performs one task. In simple terms, we can insert 3 constructors, declare 3 variables and refer to them. But as I see it, it is not quite correct. On top of that, there is one variable of the string type in two variants but it is different in name and is used in different parts of the code. Of course, you may change the sequence of variables but I think this is not quite correct either.
I read the documentation about the new operator but do not understand how it may help. I do not see the difference between three different object variables and three pointers to the same objects. Perhaps it's profitable when you create a pointer once, use this object and delete it when it is not needed. But if you need the object regularly, it's silly to create a pointer to it each time and delete it.
All in all, please help. I've read some explanations of OOP in C++, but they are described there in a way worse than in the documentation on mql5. Please do not impatient people, I will ask too many questions. I'm not interested in ready-made code without explanations either, I want to understand it, and not to stupidly repeat "Do with us, do as we do...".
We need more details. What task does the class perform?
Details are needed. What task does the class perform?
It's no secret, a sample of economic calendar events CalendarValueHistory(). In one case, all the news in the time range. In another by country and another time range. In the third one it's by a symbol. But is there a fundamental difference? Do programming lectures divide solutions by the type of tasks they perform?
I recently met someone who failed a driving test and was indignant, saying that they had not driven at that intersection in their driving lessons and simply did not know how to drive at that intersection.
In another by country and a different time range.
countries in enum
In the constructor, even through the usual switch - case, do the initialization as you need, I showed above a template with interfaces, I also initialize one of the strategies in the constructor, depending on the parameters, and the rest of the work is reduced to writing a specific strategy
https://www.mql5.com/ru/forum/85652/page24#comment_13054686
countries in enum
In the constructor, even through the usual switch - case, do the initialization as you need, I showed above a template with interfaces, I also initialize one of the strategies in the constructor depending on the parameters, and the rest of the work comes down to writing a specific strategy
https://www.mql5.com/ru/forum/85652/page24#comment_13054686
Boring... There are templates and interfaces to be mastered as well???