Questions on OOP in MQL5 - page 77

 
Vladimir Simakov:

Agree that it's more complicated now)))

I politely said nothing, although I wanted to ask for an example not to output to a log, but to a file - their logging is more practical and makes sense, and in the log of the terminal to understand what the terminal outputs, what EA - very inconvenient

 

When are we going to start making the hard links that MQ doesn't have yet?

 

standards experts, here's a question:

While ME is a mess with {} highlighting , copied the MQL code into an empty C++ project in VS2019, why does VS swear at this:

struct SHash
{
  ulong hash[2];
  bool operator==(const SHash& value)const { return(this. hash[0] == value.hash[0] && this. hash[1] == value.hash[1]); }
};

writes: "expression must be of class type"

 
Igor Makanu:

standards expert, here's a question:

While ME is a mess with {} highlighting , copied the MQL code into an empty C++ project in VS2019, why does VS swear at this:

writes: "expression must have class type"

but in C++ this is a pointer...

either override * or explicitly specify ->

 
Maxim Kuznetsov:

and in C++ this is a pointer...

Either override * or explicitly specify ->

I've gotten used to putting this in as in all the articles here, in general not to write anywhere, there are simply no options inside such simple constructions...no way, imho

 
Igor Makanu:

standards experts, here's a question:

While ME is a mess with {} highlighting , copied the MQL code into an empty C++ project in VS2019, why does VS swear at this:

writes: "expression must be of class type"

This is how it should be :

struct SHash
{
        long hash[2];
        bool operator==(const SHash& value)const { return(this->hash[0] == value.hash[0] && this->hash[1] == value.hash[1]); }
};
 
Andrei Novichkov:

This is how it should be :

I need it in MQL, I downloaded VS as an editor, to browse the code and see what I can see )))

But in such a structure for MQL - there's no sense in writing this?

 
Igor Makanu:

I need it in MQL, I downloaded VS as an editor, to browse the code and see what I can see ))))

but in such a structure for MQL - there's no sense in writing this ?

I need to check, but at first glance, this expression makes no sense not only in MQL)
 
Igor Makanu:

writing again and again - I have time (because I don't watch TV) ) ) - gathering technical information about language features, OOP... Everything in which there are questions - the forum is active, I use this opportunity "a hundred percent" ;)

The question is - what's the point of moving from C# to MQL, if I can just call my Sharp code from MQL, unless I want to put it into Market or optimize it in MQ-cloud.

After all the transition from C# to MQL, I suppose, is really painful ) After getting used to convenience and ease of working with objects, where you don't have to worry about their removal, here you get the opposite.Anyway, a full-fledged OOP requires the presence of a reference counter for referenced objects. And in C++ it's solved with a wrapper - the smart pointer. In MQL the use of smart pointers is very cumbersome because of the lack of operator ->, and other problems.

So, if switching from C++, everything is more or less clear: you get a lot of inconveniences and limitations, but in general something similar. And even some pluses (for example, higher reliability at runtime, due to guided environment). But when moving from Sharp, I don't see any pluses. Only disadvantages )

 
Igor Makanu:

I've got a knack for sticking this one in as all the articles here write, in general not to write anywhere, there are simply no options inside such simple designs...ponces, imho

In general, a lot of controversial style is imposed here)))) The same

return (retValue);

Why brackets? It's not JS, although you don't have to do it there either.

And if you really need this and that it would be in the pluses correct, then instead of this macrosubstitution

#ifdef __cplusplus
   #define THIS *this
#else
   #define THIS this
#endif