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

 

I don't understand why not prohibit implicit copying for object types? What good would it do? Objects that are actually objects and not OOP-disguised structures that can be conveniently passed by reference, don't have logic reduced to the mere content of fields anyway. That is, copying without explicitly overloading the = operator in the class just isn't necessary.

 
Ilya Malev:

Where is*?

In MQL
 

It's S. Do you want a PL?

Ilya.

 
Alexey Navoykov:
In MQL

And what does it lead to in MQL? Can you show me a simple example?

 
Alexey Navoykov:
Why wouldn't it work? There are * and & operators for converting to what's required.

It didn't work for me (in case it's banned)

class A
{
public:
  int i;
  
  void operator =( const A &Object )
  {
    this = Object;
  }
};

void OnStart()
{
  A a1;
  A* a2 = new A;
  A* b = &a1;
  
  a2 = a1; // Хочу копирование объекта
  a2 = b;  // Хочу копирование объекта  
}
 
Ilya Malev:

And what does it lead to in MQL? Can you show me with a simple example?

fxsaber:

I couldn't do it (in case they ban it)

Shit, guys, what are you doing?

A a;
A *p;
*p = a; 
 
Alexey Navoykov:

Shit, guys, what are you doing?

Area of visibility...

 
Alexey Navoykov:

Shit, guys, what are you doing?

A hundred plus for you, man. Either I've been tricked by some demon when I've tried this before, or one of the latest builds has added it.

 
Ilya Malev:

A hundred plus for you, man. Either I've been tricked by some demon when I've tried this before, or one of the latest builds has added it.

Obviously, the first one ) Because this functionality has been available in MQL for about 3 years now
 

I was sure there is no such a thing in MQL! I wonder where did the legs grow in my head...

I wonder if there's even one example of this in the QB or Documentation? Didn't bluntly notice....
Reason: