You need to show a clear contradiction (that you changed const value):
int f( int &p ) { return p = !p; }
struct X {
constint i;
X( int i ) : i( i ) {}
X( X& x ) : i( f(x.i) ) {}
};
voidOnStart()
{
X x1( 1 );
constint i = x1.i;
{ X x2 = x1; }
Print( i == x1.i ); //Результат: false - не может быть
}
And you suggest that both experienced Users and Developers should guess
My idea is to use mql5 as a forex trading system, and I would like to use it in my own practice.
Is it possible to change the fieldsof a const objectof a class or to call its non-const methods? -You can!
template <typename T>
T GetMe( const T Ptr )
{
return((T)Ptr);
}
class A
{
public:
int i;
};
voidOnStart()
{
const A a;
GetMe(&a).i = 1;Print(a.i); // 1
}
Don't like this chip myself. Thought I was insured against unauthorised access. Bummer, though! It doesn't work with const structures, of course. So keep this loophole in mind.
In b3095 I run a script:
If you remove the overload f1(T* & Ptr), all 5 calls return void f1<const X>(const X*const).
Is this some kind of feature?
Please explain:
Line *1* gives a compiler error - expected.
But line *2* compiles and works fine. Why?
Please explain:
Line *1* gives a compiler error - expected.
But line *2* compiles and works fine. Why?
You need to show a clear contradiction (that you changed const value):
And you suggest that both experienced Users and Developers should guessvalue change
Forum on trading, automated trading systems and trading strategies testing
Peculiarities of mql5 language, subtleties and tricks
My idea is to use mql5 as a forex trading system, and I would like to use it in my own practice.
Is it possible to change the fieldsof a const objectof a class or to call its non-const methods? -You can!Don't like this chip myself. Thought I was insured against unauthorised access. Bummer, though! It doesn't work with const structures, of course. So keep this loophole in mind.
You need to show a clear contradiction (that you have changed the value of const):
And you suggest that both experienced Users guess and DevelopersYes. But in your example you have an explicit (via a function) conversion of const T to T - i.e. a "legalised" loophole.
((A*)(&a)).i = 1;similarly - (const A*) convert to A*.
((A)a).i = 1;Your example explicitly converts const to non const, and there it is clean