Hi,
I need to write a function that returns 2 file handles, which are just ints, so I thought to declare the function like
int[] getFileHandles();
but MT5 didn't support returning an anonymous sized array, and wouldn't let me return a pointer to it or even to specify the size like
int* getFileHandles() or int[2] getFileHandles();
So I ended up creating a class with 2 int members and then having to call new to create it, then I'll have to delete it somewhere, which is all kind of heavy weight and a pain.
I must be missing the obvious easy way to do this, can someone show it to me?
thanks,
Rik
You have to use parameters passed by reference :
void getFileHandles(int& handle1, int& handle2) { handle1 = ... handle2 = ... ... }
You can also pass an array as parameter.
thanks, that will work. Also I found https://www.mql5.com/en/articles/567 which was useful.
Rik
- 2013.03.11
- Dmitry Fedoseev
- www.mql5.com
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi,
I need to write a function that returns 2 file handles, which are just ints, so I thought to declare the function like
int[] getFileHandles();
but MT5 didn't support returning an anonymous sized array, and wouldn't let me return a pointer to it or even to specify the size like
int* getFileHandles() or int[2] getFileHandles();
So I ended up creating a class with 2 int members and then having to call new to create it, then I'll have to delete it somewhere, which is all kind of heavy weight and a pain.
I must be missing the obvious easy way to do this, can someone show it to me?
thanks,
Rik