MQL5 The compiler does not distinguish between a class and a pointer to it - page 10

 
Ilya Malev:

And how much more time flew by before these operations were actually introduced... Only the wind probably knows. But yeah, pretty important things can be brought up on the forum for years without much success

If you don't mind scrolling forward you can see everything:

Forum on trading, automated trading systems and testing trading strategies

Bugs, bugs, questions

Ilyas, 2015.09.03 14:30


Added operators *(Dereference/Inderection) and &(Address-of), no additional language changes will be made/planned
A *a,*b;

 a== b;   // сравнение "указателей"
*a== b;   // вызов оператора ==(A *)
 a==*b;   // вызов оператора ==(A &)

// для операции != аналогично

// операция & - эквивалент(короткая запись) вызову GetPointer

 
Alexey Navoykov:

Well, if you do not get lazy and scroll forward a bit, you can see everything:

If you scroll down further, you'll find this:

Ilyas:
Added to both languages. But unfortunately, it won't make it into the next build.

In general, it's clear that about three years ago, most likely, they were added... But where is the news, where is the documentation, help, why is there only a mention of & operator and no *, if they were added at the same time? Judging by the fact that & is in the documentation and * is not, we can assume that it was * that was abandoned for some reason right before the release and finally added later. To find this out for sure, you either need to find a news post about the build where this was added, or ask the admins themselves.

 
I can give the curious builds 1047, 1085, 1210 and 1224 (around that time) for experimentation ;)

 
Andrey Khatimlianskii:
I can give you builds 1047, 1085, 1210 and 1224 (from around that time) for experimentation ;)

You can give it to me. My email is in my profile.

 
Ilya Malev:

You can give it to me. My email address is in my profile.

Maybe someone else would like it.

 
Yeah, it's a real wintry topic ))
 
47 is not running for me.
85 (MT4 13.02.15) * does not work
1210 (MT5 30.10.15) * does not work
1224 (MT5 16.12.15) * does not work (i.e. 3 spelled three months after that question thread post)

At the same time, the & in 1224 compiles to "hurrah". Which proves my hypothesis that then only & was added but not *

 

That is, originally, pointers were added to MQL without the possibility of dereferencing them in the code. This is an interesting approach.

Is it left to finish the pointer arithmetic or is it somehow already possible?

class A
{
public:

    int iValue;
};
//......................
A m_A[5];

void OnStart()
{
A* pA;

    for(int c =0; c < 5; c++)
    {
        pA = &m_A[c]; 
        
        (*pA).iValue =c;
        printf("A[%i].iValue: %i", c, m_A[c].iValue);
        // pA++
    }
}
 
SemenTalonov:
(* pA).iValue =c;

This one: (* ) is not needed here

* is only needed in µl when the operations =, ==, !=, !, && or || are applied directly to the * pointer
 
Ilya Malev:
The & in 1224, on the other hand, compiles with flying colours. Which proves my hypothesis that only & and not * were added at that time.

By the way, it may well be that since all official channels (forum, help, documentation) keep silent about the * operator, the admins may be thinking about removing it again and pretending it never existed))) So it's dangerous to rely heavily on its use at all at the moment, imho.