Errors, bugs, questions - page 1707

 
Комбинатор:
The pointer is assigned rvalue, which is then overwritten with new A.

Where? Right here?

this[0] = new A;

Here operator[] returns the value contained in cell Data[0]. Not a reference to this cell or a pointer to it, but just a copy of the value contained in this cell, i.e. rvalue. Nothing can be assigned to this copy, of course. I don't understand how operator= changes this.

 
Sergei Vladimirov:
And I still don't understand the last example. Overloading the "=" operator in class A turns this[0] from rvalue to lvalue... I can't figure out how. Is this some kind of MCL feature, there's no such behaviour in the pros.fxsaber, how did you even get to this construct? I mean overload = in A. Or by trial and error?
With full understanding I did. Otherwise I definitely wouldn't have written such a thing.

Forum on trading, automated trading systems and strategy testing

Libraries: TypeToBytes

fxsaber, 2016.09.21 21:25

Published. Now for any variable (structure or standard type) not only reading works like with array, but also WRITE:

_W(AnyVariable)[Pos] = AnyValue; // Записывает по байтовому смещению Pos значение AnyValue в переменную AnyVariable

It wasn't easy to guess before the implementation - probably turned out to be a good test of average OOP proficiency: I only know the classics for classes.

If anyone knows something similar, please share the link for education.


 
fxsaber:
With full understanding I did. Otherwise I wouldn't have written such a thing.

So you understand everything, but you can't say it? )) I see.
 
Sergei Vladimirov:
So you understand everything, but you can't say it? )) I see.
Yeah, well, it happens. I can't formulate it. That's why I'm asking the developers to do it properly.
 
Sergei Vladimirov:

Where? Right here?

this[0] = new A;

Here operator[] returns the value contained in cell Data[0]. Not a reference to this cell or a pointer to it, but just a copy of the value contained in this cell, i.e. rvalue. Nothing can be assigned to this copy, of course. I don't understand how operator= in the A class changes this.

Perhaps it's all about those same issues with references in MCL.

A* operator []( const int Pos )
{
    return(this.Data[Pos]);
}

It may turn out that it's not the value returned here, but rather a reference to it, i.e. lvalue... But why can't it be assigned a new value right away, why do we need operator= in the A class? I don't understand...

 
Sergei Vladimirov:

Probably, it's all about the same reference stuff in MKL.

As if it didn't turn out that it's not a value that's returned here, but a reference to it, i.e. lvalue... But why can't it be assigned a new value right away, why do we need operator= in the A class? I don't understand...

When you assign something to a rvalue-pointer, the pointer is automatically cast to an object reference. Well, everybody was born yesterday!

I've been asking the Desk for that for a long time, but they say it's not safe, although in fact it's not any more dangerous than passing arguments by reference.

 
Alexey Navoykov:

When you assign something to a rvalue-pointer, the pointer is automatically converted to an object reference. It's like yesterday, isn't it?

I understand it now, thank you.
 
The ability to highlight row(s) in the ribbon is lacking. I can look at it, but I can't highlight it.
 
What the hell is this?
2016.09.26 14:02:11.858 Books   invalid book item[RTS-12.16,buy,98090.00000,-16]
 

Type mismatch

MqlTick time_msc - long.

CopyTicks from - ulong.