M1cha31: encountered an error stating " object of 'Order' cannot be returned, copy constructor 'Order::Order(const Order &)" on POrder class. What should I do to fix it? |
|
MQL function cannot return an array.
You can return a pointer to the single object of the Order type
Order* getOrders(){ // Note "*" after the Order. You can return "pointer" to object return(orders[0]); // You can return single object of the Order type }
If you want to return an array of objects, you can use CArrayObj class. It's located in the include file <Arrays\ArrayObj.mqh>.
Alternative is to send an empty array as a parameter and then fill it with objects:
// this code is not tested void getOrders(Order &ords[]){ ArrayCopy(ords, orders, 0, 0); }
M1cha31: encountered an error stating " object of 'Order' cannot be returned, copy constructor 'Order::Order(const Order &)" on POrder class. What should I do to fix it? |
|
Hi,
Thanks for the feedback. Can you give me snapshots (or link to a resources) that explains how to pass pointer to a class and creating a copy-able constructor.
MQL function cannot return an array.
You can return a pointer to the single object of the Order type
If you want to return an array of objects, you can use CArrayObj class. It's located in the include file <Arrays\ArrayObj.mqh>.
Alternative is to send an empty array as a parameter and then fill it with objects:
- 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 all,
I'm just starting to code using mql4 and encountered an error stating " object of 'Order' cannot be returned, copy constructor 'Order::Order(const Order &)" on POrder class. What should I do to fix it?
Best,