Errors, bugs, questions - page 1979

 
Andrey Barinov:
Thank you. I've never encountered this in the documentation. Can you point it out?
He came up with this rule himself. The documentation says:

Accordingly, testfunc() can only (and only) be accessed from cA:: methods -> in this case from cA::test()

 
A100:
And did you try to compile this example in C++ - or is it just general theoretical reasoning?

Have you tried following the link? You can not only compile there, but also execute the example successfully.

 
Stanislav Korotky:

Have you tried following the link? You can not only compile there, but also execute the example successfully.

Why then such code doesn't work?

class cA;
class cB;
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
class cA
  {
private:
   int               m_var;
   int               m_func(void){return(this.m_var);}
public:
   void test(cB &b)
     {
      this.m_var=b.m_var;      // (1) 'm_var' - private member access error
       
      this.m_var=b.m_func();   // (2)  => norm
     }
  };
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
class cB : public cA
  {
  };
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   cA A;
   cB B;

   A.test(&B);
//---
   return(INIT_SUCCEEDED);
  }


I don't see any difference between (1) and (2).

 
Stanislav Korotky:

Have you tried following the link? You can not only compile there, but also execute the example successfully.

We are discussing the specific code given above. If you haven't tried it, just write
 
Andrey Barinov:

Why then does this code not work?

Now the 2nd theorist will give you another rule, no less vague than the first one

I propose to simplify the code to the limit

 
A100:
The specific code above is under discussion. If you haven't tried it, just write it so

It is the code above that has been tweaked for C++ syntax - actually left one-to-one in the context of the private member access discussion - and that code works. This was the answer to the question why it works in MQL. What else do you need? What else do you want me to try? Don't write nonsense yourself.

 
Stanislav Korotky:

It was the code above that was tweaked for C++ syntax - in fact it was left one-to-one in the context of the private member access discussion - and that code works. This was the answer to the question why it works in MQL. What else do you need? What else do you want me to try? Don't write nonsense yourself.

You can post it here and let's compare how you fixed it then (I don't go to links on left sites). If you do not know how to communicate normally - (I mean bullshit) do not write

 
Andrey Barinov:

Why then does this code not work?


I don't see any difference between (1) and (2).

This is an MQL bug. It works in C++. Write to service-desk.

 
Stanislav Korotky:

This is an MQL bug. In C++ it works. Write to the service-desk.

Got it. Thanks.

It's just that it's interesting in the second example. cB doesn't know anything about m_var and m_func and they are not available to it (i.e. they cannot be called from inside cB itself), while they can be called from other objects...
 
A100:

Post it here and let's compare then how you tweaked it (I don't follow links to leftist sites). If you do not know how to communicate normally - (I mean bullshit) do not write.

Do not be rude. You are the first to communicate abnormally here.

The entire Internet consists of left-wing sites. How can you use it?

This particular site and many others like it significantly simplify the life of programmers (allowing them to test snippets, http-requests, check the mapping sites, etc.) - how to treat them is up to everyone - do not want do not use, but do not go on others about it to attack.