Hello everyone. Sorry for my English.
This code gives me compile error.
'Class2' - declaration without type Class1.mqh
I need to communicate two classes because the class one has elements that need class two and one class, need to access the elements of class two.
Not possible in MQL4, make cross-references between classes?
I do not understand. Any help?. Thanks
class Class2; class Class1 { private: Class2 *class2; public: Class1(){}; ~Class1(){}; }; class Class2 { private: Class1 *class1; public: Class2(){}; ~Class2(){}; };
Thank you very much angevoyageur. Testing, I found that if used includes the declaration of the class should come first, that no error.
class Class2; #include <Class2.mqh>
class Class1; #include <Class1.mqh>
@WHRoeder
Just a thought...what about creating a base class with static class members (variables) and then create an new class derived from the base class to doing whatever needs to be done? Wouldn't that give the derived class the ability to both see and change the inherited data members of the base class? Moreover, wouldn't that also give all classes derived from the base class the ability to see (and, if needed, change--maybe depending on the abilities of the derived class) the data contained in the variables of the base class?
To be honest, while I'm not quite new to concepts of OOP, it has been a few years since I have implemented them, so like allot of people here, I'm attempting to refresh myself. :)
@WHRoeder, @Thirteen
I gave an answer to the opening poster to resolve his issue, but I agree with you. I can't think a situation where such design is the best solution and in my opinion it's certainly a bad practice to work this way. Though it could be interesting to hear @estados about the purpose of his implementation.
I had a similar challenge, though I'm not sure it corresponds to the OP requirements.
My classes were of the same structure and conceptually on the same level. In that case, using an interface solved it elegantly.

- 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 everyone. Sorry for my English.
This code gives me compile error.
'Class2' - declaration without type Class1.mqh
I need to communicate two classes because the class one has elements that need class two and one class, need to access the elements of class two.
Not possible in MQL4, make cross-references between classes?
I do not understand. Any help?. Thanks