class A { public:
virtualvoid f() { Print( __FUNCTION__ ); }
};
class B : public A { public:
virtualvoid f() { Print( __FUNCTION__ ); }
};
class H { public:
H( A* a ) { H::s[ 0 ] = a; }
staticvoid g();
static A* s[ 1 ];
};
A *H::s[ 1 ] = { 0 };
void H::g() { H::s[ 0 ].f(); } //еще обратил внимание, что в этом месте редактор выделяет (.f) зеленым
voidOnStart()
{
A* b = new B();
H h( b );
H::g(); //печатает A::f()
delete( b );
}
What to do with spammers in the market? I complained, the spammer was banned for 24 hours, now he's been unbanned, but his shit is still there. Or is it normal? Isn't the product discussion page for customer feedback?
Compilation error 358 in all cases of calling h( A* a)
class A {
};
class B {
public:
B() : a1( NULL ), a2( NULL ), a3( NULL ), a4( NULL ) {}
void f() const {
h( a1 ); // не обоснована (1)
h( a2 ); // не обоснована (2)
h( a3 ); // обоснована (3)
h( a4 ); // обоснована (4)
}
A * a1;
A * const a2;
const A * a3;
const A * const a4;
};
void h( A* a )
{
}
It is justified only in (3) and (4) because it is not h( const A* a)
A similar situation was corrected earlier https://www.mql5.com/ru/forum/1111/page1218#comment_1058402 but the reason is probably different since presence of const in void f() const declaration influences error occurrence and there were no member functions there
It does not compile in build 976 (error 358, but differs from previously described errors in build 975).
class A {};
struct S { int s; };
void h1( A* a ) {}
void h2( S& s ) {}
void h3( const S& s ) {}
class B {
public:
void f1() const { h1( this.a ); } //не обоснованная и возникла только в build 976
// void f2() const { h2( this.s ); } // обоснованная ошибка в build 976void f3() const { h3( this.s ); } //нормально
A* a;
S s;
};
The reason might be that build 976 fixed the error relating to the fact that a normal function called from a const class method could modify class members passed to it by a non-const& reference. But here the pointer is a class member and its value is guaranteed not to be changed when calling h( A* a), but can only be changed when declaring h( A* &a )
Does not compile in build 976 (error 358, but differs from previously described in that no errors occurred in build 975)
The reason might be that build 976 fixed the error relating to the fact that a normal function called from a const class method could modify class members passed to it by a non-const& reference. But here the pointer is a class member and its value is guaranteed not to be changed when h( A* a) is called but can be changed only when h( A* &a ) is declared.
An error in the operation of virtual functions
Result: A::f(), should be B::f()
Help install META TRADER 4 on OS MAVERICKS, DOWNLOADED ALL PROGRAMS, PLAY ON MAC, ALL NEW, ANYTHING GIVES ERROR.
/*moderator: send the error text as a file*/
2 - Before debugging.
3 - after.
Maybe there are differences there, I don't understand anything at all)
Thank you very much)
Compilation error
while const should not follow static
Also, this is a sham protection, because static is modified by the usual h() function and A::f() const won't even know about it
An error in the operation of the virtual functions
Result: A::f(), should be B::f()
Compilation error
while const should not follow static
Also, this is a sham protection, because static is modified by the usual h() function and A::f() const won't even know about it
Compilation error 358 in all cases of calling h( A* a)
It is justified only in (3) and (4) because it is not h( const A* a)
A similar situation was corrected earlier https://www.mql5.com/ru/forum/1111/page1218#comment_1058402 but the reason is probably different since presence of const in void f() const declaration influences error occurrence and there were no member functions there
It does not compile in build 976 (error 358, but differs from previously described errors in build 975).
The reason might be that build 976 fixed the error relating to the fact that a normal function called from a const class method could modify class members passed to it by a non-const& reference. But here the pointer is a class member and its value is guaranteed not to be changed when calling h( A* a), but can only be changed when declaring h( A* &a )Does not compile in build 976 (error 358, but differs from previously described in that no errors occurred in build 975)
The reason might be that build 976 fixed the error relating to the fact that a normal function called from a const class method could modify class members passed to it by a non-const& reference. But here the pointer is a class member and its value is guaranteed not to be changed when h( A* a) is called but can be changed only when h( A* &a ) is declared.