Errors, bugs, questions - page 1920

 
fxsaber:

The "ancestor" sees the protected/private fields and shouldn't.

And public fields: should/should not?

Combinator:

If we add

struct B;

No effect
 
A100:

And public: should/should not?

public static field - must.
 
fxsaber:
public static-field is a must.
To summarize: The base class does not see the non static field of the derived one. At the same time, the base class does not see protected static of the derivative, but sees public static. Did you invent this rule yourself?
 
A100:
To summarize: A base class does not see non static fields of a derived one. At the same time, the base class does not see protected static of the derived one, but sees public static. Did you invent this rule yourself?

It is difficult for me to say where such generalisations are made. I didn't have that in mind in any way myself.

Any class sees public static fields/methods of any other class.

Base class never sees protected/private (static - whatever) fields/methods of derived (public-inheritance) class.

A derived class(public-inheritance) never sees private fields/methods of a base class, but always sees protected/public.

 
fxsaber:

Any class sees public static fields/methods of any other class.

In the end, the question comes down to this: Is it correct that in MQL, public static fields/methods of a derived class are available in a base class?
 
A100:
In the end, the question comes down to this: Is it correct that public static fields/methods of a derived class are available in MQL?

This is correct not only for the base/derivative case, but for any classes in general.

 
fxsaber:

This is correct not only for the base/derivative case, but for all classes in general.

The question did not arise out of nothing

#ifdef __cplusplus
struct B;
struct A {
        int f() { return B::i; } //error E2451
};
struct B : A {
        static int i;
};
int B::i;
#endif
and therefore needs to be checked in detail
 
fxsaber:

Any class sees public static fields/methods of any other class.

... Including the base class. Hence the following contradiction in MQL

struct A {
        static int i;
};
int A::i;
struct B : private A {};
struct C : B {
        C() { Print( A::i ); } //error: 'i' - private member access error
};
C++ without errors
 
A100:

In C++ by default in structures members are public, in mql private, same as in classes.

Yes, I was wrong, forward declaration in C++ is missing, we need definition

 
A100:

... including the basic one. Hence the following contradiction in MQL

C++ without errors

Yes, this is a bug in MQL private inheritance.

Reason: