for double I know it pass like above
but how about this?
how can I pass the array as an argument into the function?
There is no difference.
MqlRates Bar_Rates[]; double Distance(MqlRates &rates[]) { //--- return 0.; }
There is no difference.
thanks, tried and works perfectly
any difference using
double Distance(MqlRates &rates[])
or
double Distance(MqlRates& rates[])
thanks, tried and works perfectly
any difference using
or
What the compiler and debug says ?, if it's fine, than its OK.
Old post with old build of MT5 https://www.mql5.com/en/forum/631
- www.mql5.com
thanks, tried and works perfectly
any difference using
or
What the compiler and debug says ?, if it's fine, than its OK.
Old post with old build of MT5 https://www.mql5.com/en/forum/631
I am passing a reference to MqlRates and using this in my class.
However when I try to save this reference as I use it many times in the class, I get an error. Is there a solution to store a reference?
MyClass
private MqlRates myrates[];
Public:
void SetMyRates(MqlRates rates[]){myrates = rates;} //Attempting to store the reference fails
I can use the reference in the array directly, but is there a solution for storing the reference in my class for repeated use? Thank you.
MqlRates rates_original[]; void test_function(MqlRates &reference[]) { int total=ArraySize(reference); if(total>0) Print("Open : "+reference[0].open); }
reference may be confusing , think of it as "telling the function which rates array to read"
void runtest() { ArrayResize(rates_original,5,0); rates_original[0].open=1.25; test_function(rates_original);//telling it where to read from }
And I prefer the other way; a variable that is a reference to a type. Sixty (60) years since C first came out; still no consensus.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
for double I know it pass like above
but how about this?
MqlRates Bar_Rates[];
how can I pass the array as an argument into the function?