Why can't you encapsulate a nested struct or class?

 

Is there a reason why you cannot encapsulate a nested struct or class like in C++? Here is an example.

void OnStart(){

   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

 
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.

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.

MetaQuotes acknowledged this was a bug, but said they won't fix it.

See this thread - https://www.mql5.com/en/forum/151183  

ServiceDesk

The compiler shouldn't allow the declaration/creation of a private structure/class outside of the enclosing class. Compare the above behavior to that C++. 
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
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:

MetaQuotes acknowledged this was a bug, but said they won't fix it.

See this thread - https://www.mql5.com/en/forum/151183  

Ok thanks. Is there a list of known issues/ quirks/ idiosyncrasies with MQL5?
 
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...?
Reason: