class B; class A { B *m_b; }; class B { A *m_a; };
Hello,
I don't know how to make a forward reference between two classes (contained in two different files):
[file A.mqh]
[file B.mqh]
Clearly this won't compile as the declaration "myclassA" is defined as having no type. Even explicitly including file A.mqh has no efect. Putting both classes in one file is ovbiously the same.
How can i make possible this kind of recursion in MQL5?
Thank you guys.
[EDIT]: I believe this one should go in the GENERAL DISCUSSION, sorry, i read this topic after posting: https://www.mql5.com/en/forum/6775
Hi TripleHeinz
Include : https://www.mql5.com/en/docs/basis/preprosessor/include says "The preprocessor replaces the line #include <file_name> with the content of the (include) file ... ".
- www.mql5.com
Hello,
I don't know how to make a forward reference between two classes (contained in two different files):
[file A.mqh]
[file B.mqh]
Clearly this won't compile as the declaration "myclassA" is defined as having no type. Even explicitly including file A.mqh has no efect. Putting both classes in one file is ovbiously the same.
How can i make possible this kind of recursion in MQL5?
Thank you guys.
[EDIT]: I believe this one should go in the GENERAL DISCUSSION, sorry, i read this topic after posting: https://www.mql5.com/en/forum/6775
Just add the line `class {ClassName};` above the #include line to make it compile:
[file A.mqh]
class B; #include "B.mqh" class A { B* myclassB; };
[file B.mqh]
class A; #include "A.mqh" class B { A* myclassA; };
So lonG
Daniel
- 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,
I don't know how to make a forward reference between two classes (contained in two different files):
[file A.mqh]
[file B.mqh]
Clearly this won't compile as the declaration "myclassA" is defined as having no type. Even explicitly including file A.mqh has no efect. Putting both classes in one file is ovbiously the same.
How can i make possible this kind of recursion in MQL5?
Thank you guys.
[EDIT]: I believe this one should go in the GENERAL DISCUSSION, sorry, i read this topic after posting: https://www.mql5.com/en/forum/6775