You can't do that in C++ either. The private_nested is private, therefor it's not available outside that class.
whroeder1:
You can't do that in C++ either. The private_nested is private, therefor it's not available outside that class.
You can't do that in C++ either. The private_nested is private, therefor it's not available outside that class.
Exactly! This should not compile, yet it does. The compiler is treating it as a global declaration instead of private.
nicholishen:
Exactly! This should not compile, yet it does. The compiler is treating it as a global declaration instead of private.
Exactly! This should not compile, yet it does. The compiler is treating it as a global declaration instead of private.
MetaQuotes acknowledged this was a bug, but said they won't fix it.
See this thread - https://www.mql5.com/en/forum/151183
ServiceDesk
Unfortunately, this behaviour won't be changed. Don't use such members if you prefer C++ style. Sorry.

Question regarding encapsulating a private structure definition inside a class
- www.mql5.com
Consider the following class definition: My goal was to create a private structure definition inside a class which would neither be accessible or...
honest_knave:
Ok thanks. Is there a list of known issues/ quirks/ idiosyncrasies with MQL5?
MetaQuotes acknowledged this was a bug, but said they won't fix it.
See this thread - https://www.mql5.com/en/forum/151183
IMHO a class is a kind of more sophisticated struct in terms of variables. Both contain variables of different types - but what is the intention and where is the benefit of a class with structs?
To me it looks a bit like structs of structs of structs...?
To me it looks a bit like structs of structs of structs...?

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Is there a reason why you cannot encapsulate a nested struct or class like in C++? Here is an example.
BClass b_object;
b_object.private_member_of_A.data1 = 10;
printf(IntegerToString(b_object.private_member_of_A.data1));
}
//+------------------------------------------------------------------+
class AClass{
private:
struct ClassA_Private_Nested_Struct{
int data1;
};
};
class BClass{
public:
ClassA_Private_Nested_Struct private_member_of_A;
};
Output: 10