I've these two simple files:
Trade.mqh
class Trade;
class Trade {
public:
#include "Order.mqh"
struct TradeRequest {
ENUM_ORDER_STATE type;
};
};
Order.mqh
class Order;
class Trade;
#include "Trade.mqh"
class Order : public Trade {
public:
enum ENUM_ORDER_STATE {
ORDER_FOO,
ORDER_BAR
};
TradeRequest order;
};
However the compilation fails.
How do I fix the compilation problem without keeping the same files and not moving the structure to one file?
I want to keep the structure how it is (two separate files), trade related struct in Trade class file which has dependency to order related enum which is defined in Order class file.
The errors are:
MQL4/MQL5 for Trade.mqh
'Trade' struct undefined (Order.mqh)
'TradeRequest' - declaration without type (Order.mqh)
MQL4 for Order.mqh
'ENUM_ORDER_STATE' - declaration without type (Trade.mqh)
'Trade' - struct undefined (Order.mqh)
';' - unexpected end of program (Order.mqh)
In MQL5 compiles, but with the warning that enumeration already defined.
Declare enum
above class Trade
, I do not think there's any reason to assign enum
as property of the class.