Errors, bugs, questions - page 1980

 
Stanislav Korotky:

Don't be rude. You were the first to start the abnormal communication here.

By asking about compiling in C++ ? In my opinion, it's a normal working question.
 
Andrey Barinov:
For your reference, if both your examples are clearly translated into C++, then C++ will give an error in both cases. MQL does not give an error in the 1st case only because the compilation process (and not the language itself) is different
 
A100:
By asking about compiling in C++ ?

With these two passages:

Have you tried compiling this example in C++ - or is this general theoretical reasoning?

in response to the working example in C++ I gave, as well as

If you haven't tried it - write it that way.

In reply to my example, I just tried it.

 
Stanislav Korotky:

With these two passages:

in response to the working example I gave in C++, and also

in response to what I just tried.

When writing ServiceDesk, do you also cite code on a third-party site as an example? And if not, why not?
 
A100:
For your reference, if both your examples are clearly translated into C++, then C++ will give an error in both cases. MQL does not give an error in the 1st case only because the compilation process (and not the language itself) is different

Thank you.

 
Andrey Barinov:

Thank you.

So as not to be unsubstantiated, I give the analogue to the last one (tweaked it a bit in my own way):

#ifdef __cplusplus
class B;
class A {
        int f( B* b ) { return b->i; } //Error: E2315
        int i;
};
class B : public A {};
#endif

and to the original message

#ifdef __cplusplus
class B;
class A {
        void f() {}
        void g() { b->f(); } //Error: E2315
        B *b;
};
class B : public A {};
#endif
 

I checked, Stanislav's variant compiles successfully in VS 2010. In addition, access to private field also works, not only to method. So, maybe A100 was a bit too much in his conclusions this time).

 
Alexey Navoykov:

I checked, Stanislav's variant compiles successfully in VS 2010. In addition, access to private field also works, not only to method. So, maybe A100 was wrong in his conclusions this time )

Is it exactly the same as https://www.mql5.com/ru/forum/1111/page1999#comment_5677254?

Above are my options... post the code here - if he can't post it himself

Ошибки, баги, вопросы
Ошибки, баги, вопросы
  • 2017.08.29
  • www.mql5.com
Форум алго-трейдеров MQL5
 
A100:

Does it exactly match https://www.mql5.com/ru/forum/1111/page1999#comment_5677254?

Above are my variants. post the code here - since he can't post it himself

What compiler did you use to compile it? My VS 2010 doesn't compile your code for a completely different reason: the B class is not defined where the method of that class is called. You need to put definition of g() outside the class for that. And this is exactly what Stanislav did. I.e. your code should be like this:

class B;
class A {
  void f() {}
  void g();
  B *b;
};
class B : public A {};


void A::g(void)
{
  b->f();
}

and it compiles.

 
Alexey Navoykov:

What compiler did you use to compile this?

Basically it doesn't change anything - compilation error (I have a tablet - Borland compiler)

#ifdef __cplusplus
class B;
class A {
        void f() {}
        void g();
        B *b;
};
class B : public A {};
void A::g() { b->f(); } //Error: E2247
#endif
Reason: