Your mqh file doesn't compile.
If you want to report an issue, please provide ALL steps to reproduce it.
Which build are you using ?
I've reported the issue already. I need 1) know if the file is correct, 2) how to fix it if not.
I've attached the actual file I'm using although the one above compiled for me also.
I'm using MetaEditor v5.0 1601 19 May 2017
Thanks.
You need to templatize the class and not the individual elements/methods of the class. Here is a quick-and-dirty...
***See diff from the original mqh.
#include <carrayringT.mqh> void OnStart() { CArrayRing<int> ring; ring.Init(10); for(int i=100000; i>=0; --i) ring.Add(i); for(int i=ring.Size()-1; i>=0; --i) Print(ring[i]); }
- Jamie Peabody
- www.mergely.com
I've reported the issue already. I need 1) know if the file is correct, 2) how to fix it if not.
I've attached the actual file I'm using although the one above compiled for me also.
I'm using MetaEditor v5.0 1601 19 May 2017
Thanks.
I confirm it crashes with this build 1601. It doesn't crash with ME build 1910.
Your mqh file compiles because it doesn't use #property strict, if you use it (which is recommended) it doesn't compile.
You need to templatize the class and not the individual elements/methods of the class. Here is a quick-and-dirty...
Thanks for your help.
That seems to work except when I try to create a type of a struct.
For instance:
struct S_BUFFER { double s; double st; double p; } CArrayRing<S_BUFFER> *buffer;
Creates this error
'CArrayRing' - identifier already used
Is this normal? Can I not use structure or class types? If I doing something wrong then what is it please.
Thanks in advance.
I confirm it crashes with this build 1601. It doesn't crash with ME build 1910.
Your mqh file compiles because it doesn't use #property strict, if you use it (which is recommended) it doesn't compile.
Thanks, worth knowing.
Thanks for your help.
That seems to work except when I try to create a type of a struct.
For instance:
Creates this error
Is this normal? Can I not use structure or class types? If I doing something wrong then what is it please.
Thanks in advance.
You have this compiling error because you need to add a ; at then of your struct declaration.
struct S_BUFFER { double s; double st; double p; };
But you will have other compilation errors as a struct can't always be used in place of a standard type.
Thanks.
You were too quick. I've just noticed that however, the error now is:
'S_BUFFER' - objects are passed by reference only
And I'm not sure how to adjust the code to do this tried adding a & to the Init volue value but that doesn't seem to have any impact.
Thanks again!
Thanks.
You were too quick. I've just noticed that however, the error now is:
And I'm not sure how to adjust the code to do this tried adding a & to the Init volue value but that doesn't seem to have any impact.
Thanks again!
Mql isn't like c++ in those regards. Structs have to be passed by reference and cannot be converted to pointers. Classes can be pointers, but create all new dynamics for this sort of thing. If you want to use structs in this collection then you need to specialize this collection for stucts.
Thanks.
You were too quick. I've just noticed that however, the error now is:
And I'm not sure how to adjust the code to do this tried adding a & to the Init volue value but that doesn't seem to have any impact.
Thanks again!
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello,
This is the first time that I've used the keyword template so I'm not sure I'm using it correctly.
I've modified Konstantin Gruzdev's CArrayRing buffer found here: https://www.mql5.com/en/code/1340 to allow any type to be added to the buffer. However,
when i use it, the MT4 editor crashes violently.
The code that I type is this:
CArrayRing *buffer; buffer = new CArrayRing(); buffer.Init
and it is exactly when I enter the ( of the Init method the editor crashes.
What am I doing wrong?
Here's my modified code: