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
1) thought there was an error here:
Section: Passing parameters to the constructor"Init() function is set aside in section private section to ensure that the class can be reinitialised."
possible:
Init() function is set aside in the public section to provide the possibility of reinitialising the class.
2) Please give an example of using the"create an array with class instances (objects)" feature for the "ObjectArray" section. Unfortunately, I can't figure out "what this is used for".
3) In the section "More about encapsulation (private, protected, public)", the base class->class descendant is mentioned in passing. Perhaps this datum(class Class: public CBase) should be explained at the beginning of the section, because I realised it later.
4) did not find:Fig.6. The visibility of the "extra" function (red arrow) is determined by the type of pointer with which the class is loaded. This example can be found in the appendix in the file OOP_sDefaultVirtual_1.mq5.
5) I didn't find a clear indication of what a library is. Apparently, a way of storing the class(es) of functions? i.e. similar to the include file, only the include file is stored as a source, and the library as a compiled dll?
Thank you very much for the article! I was especially pleased with the consistent presentation of the material.
1) thought there was an error here:
Section: Passing parameters to the constructor"Init() function is set aside in section private section to ensure that the class can be reinitialised."
possible:
Init() function is set aside in the public section to provide the possibility of reinitialising the class.
2) Please give an example of using the"create an array with class instances (objects)" feature for the "ObjectArray" section. Unfortunately, I can't figure out "what this is used for".
3) In the section "More about encapsulation (private, protected, public)", the base class->class descendant is mentioned in passing. Perhaps this datum(class Class: public CBase) should be explained at the beginning of the section, because I realised it later.
4) did not find:Fig.6. The visibility of the "extra" function (red arrow) is determined by the type of pointer with which the class is loaded. This example can be found in the appendix in the file OOP_sDefaultVirtual_1.mq5.
5) I didn't find a clear indication of what a library is. Apparently, a way of storing the class(es) of functions? i.e. similar to the include file, only the include file is stored as a source, and the library as a compiled dll?
Thank you very much for the article! I was especially pleased with the consistent presentation of the material.
1. Yes.
2. There is an example in the section "Array of objects", actually the whole section is an example with a description.
3. It is considered in the section "Using OOP to change the logic of programme operation".
4. The words "This example is in the appendix in the file..." means that the file contains an example for the section indicated by the section header. This does not mean that the examples duplicate everything written about in the article. These examples may not exist at all, everything is written in the article. But the examples are there, you can take them as a basis and experiment. The article is primary, the examples are secondary.
5. Уже давно указано: http://ru.wikipedia.org/wiki/%C1%E8%E1%EB%E8%EE%F2%E5%EA%E0_(%EF%F0%EE%E3%F0%E0%EC%EC%E8%F0%EE%E2%E0%ED%E8%E5)
Very interesting article, written in a competent "accessible" language.
Thank you to the author.
I have two examples of code based/copied from this article. They both create an array of pointers to a class and then delete them upon exit. However, one exits with a memory leak the other exits without a memory leak. The only difference is the 2nd example has the 'Alert' in the destructor commented out. When the alert in the destructor is removed there is a memory leak. This is very weird. Can anyone explain??? Please help, this is driving me CRAZY.
At the end of the examples of code from this article I have included an extremely simple example of code i wrote that also has a memory leak. Again, why???? There is nothing complicated about this final example of code...
This code works without a memory leak:
Messages from expert log, note no leaked memory:
PI 0 OOP_sConstDestr_2 (EURUSD,M1) 13:57:59 Destructor 0
KP 0 OOP_sConstDestr_2 (EURUSD,M1) 13:57:59 Destructor 1
JG 0 OOP_sConstDestr_2 (EURUSD,M1) 13:57:59 Destructor 2
EN 0 OOP_sConstDestr_2 (EURUSD,M1) 13:57:59 Destructor 3
LF 0 OOP_sConstDestr_2 (EURUSD,M1) 13:57:59 Destructor 4
OM 0 OOP_sConstDestr_2 (EURUSD,M1) 13:57:59 Destructor 5
FD 0 OOP_sConstDestr_2 (EURUSD,M1) 13:57:59 Destructor 6
IK 0 OOP_sConstDestr_2 (EURUSD,M1) 13:57:59 Destructor 7
HS 0 OOP_sConstDestr_2 (EURUSD,M1) 13:57:59 Destructor 8
CJ 0 OOP_sConstDestr_2 (EURUSD,M1) 13:57:59 Destructor 9
This code exits WITH a memory leak!!!! Why????????? The only difference is commenting out the 'Alert' in the destructor...
Messages from expert log, note leaked memory:
FM 1 OOP_sConstDestr_2 (EURUSD,M1) 13:51:19 10 undeleted objects left
EG 1 OOP_sConstDestr_2 (EURUSD,M1) 13:51:19 10 objects of type CName left
GO 1 OOP_sConstDestr_2 (EURUSD,M1) 13:51:19 200 bytes of leaked memory
Final example, my code, very simple but exits with a memory leak....
Messages from expert log, note leaked memory:
MR 0 tester (EURUSD,M1) 14:07:23 Last Error- 0 Current time: 2013.02.06 23:07:23
FL 1 tester (EURUSD,M1) 14:07:23 10 undeleted objects left
KN 1 tester (EURUSD,M1) 14:07:23 10 objects of type CCandleStick left
JS 1 tester (EURUSD,M1) 14:07:23 160 bytes of leaked memory
I have two examples...
Checked all three varaints. All three are identical. All are normal. None gives leaks. In these examples, it can not be - we have the array, in each element of the array have instance, when finishing we delete all objects. Objects do not create copies of themselves, you can not miss to delete samething. If object creates the copy of himself, then we can have difficulties with deleting, very easy to miss something. Show variants that realy have leaking.
Use SRC button to insert code (better - attach files).
Sorry for my english:)
Checked all three varaints. All three are identical. All are normal. None gives leaks. In these examples, it can not be - we have the array, in each element of the array have instance, when finishing we delete all objects. Objects do not create copies of themselves, you can not miss to delete samething. If object creates the copy of himself, then we can have difficulties with deleting, very easy to miss something. Show variants that realy have leaking.
Use SRC button to insert code (better - attach files).
Sorry for my english:)
Thanks so much for taking the time to reply. I'm not sure you saw my follow up question. It was in a separate comment that probably got deleted because I'm not very familiar with this forum. However, I tried running all three examples on an older computer with a older version of MetaTrader. In the older version all 3 seemed to work fine. It did not generate an expert log 'memory leak' error, I think it was build 560???, for any of the code examples. I believe it was build 560?? I do not remember and I upgraded the 560 to the new 756 build. After the new build I have the same memory leak problems. Is it possible the old build did not report the memory leak problems because it wasn't a feature? What build are you using? Thanks again.