The future of MQL5 is MQL5+ or even MQL6 - page 11

 
Alexey Kozitsyn:

You've got it all figured out. Use a NULL constant.

Let me tell you a secret, it's already implemented. You need to click on the mouse wheel and there will be a crosshair.

You can do it a long time ago. From the navigator you drag the indicator to the window with the indicator already attached.

IMHO, it is not the most necessary thing.

You have a navigator, you have favourites, you have templates, you have profiles. Everything can be set up. Read Help for the terminal, you will discover a lot!

Enumerations are used to make code more readable, to remove constants and replace them with entities known to man.

For example, values of enumeration ENUM_DAY_OF_WEEK can be used for comparison with value day_of_week of structure MqlDateTime. I.e. you can write it like this

Or you can write it differently:

SUNDAY is a named constant of int type with value 0.

What do you think, how will it be clearer to a person reading the code?

Cool! Thank you for the navigator! Didn't pay much attention to it. I usually turn it off, so it won't take up too much space. The help, even if just a glimpse, I've read it. It does not tell me anything about dragging an indirect in the window of charts and on top of each other. Although, I could have guessed it and tried....)))

Thanks for explaining the nature of the enumerations! I read them very quickly, MQL is mostly derived from C++, and there are a lot of docks for it. But a lot of misprints in Help and incomplete articles is not good.

Results: correctly written help may help to avoid a lot of stupid questions from dummies on the forum!

As far as NULL is concerned, it's zero - it's used a lot. But maximum values of variables are very rarely, almost never. For example, a variable stores three states after analyzing indicators: BUY, SELL or NULL. If we use ready made constants POSITION_TYPE_BUY, POSITION_TYPE_SELL, one of them is zero. I'm sure EMPTY_VALUE will be more popular than NULL if you generalize it to all the types).

 
Alexander Puzanov:

There is another infinitely useful application. For example:

And the user gets a drop-down list with a choice of 4 items of what you have written there in the comments - "Buy only", "Sell only", etc. Very useful for listing a set of indicators, timeframes, a set of conditions etc. in the user settings window

Yes, of course! In this case we can also add that it simplifies the mechanism of checking the values entered by the user by the program. I.e. all of them (correct values) are described initially.
 
agvozdezkiy:

The NULL part is zero, and it is used often. For example, the variable stores three states after analyzing indicators: BUY, SELL or NULL. If we use ready constants POSITION_TYPE_BUY, POSITION_TYPE_SELL, one of them is NULL.

No problem, you can do it that way:

#define  VALUE_EMPTY -1       // Пустое значение для числовых типов данных
#define  STR_VALUE_EMPTY ""   // Пустое значение для строкового типа

And put it wherever you want.

 
Alexey Kozitsyn:

No problem, you can do it that way:

And put it where you want it.

It's all understandable. That's not what I mean.
 
agvozdezkiy:
All this is clear. That's not what I mean.

Then explain what you mean? A single constant for all predefined data types? It is unlikely that such a thing will be implemented.

 
Renat Fatkhullin:

Unfortunately, only experienced programmers understand the usefulness and importance of such a warning.

Well, I recommend everyone else to be glad of this level of compiler's help and fix their own errors. These are real places of potential errors and it is exactly for novice developers that it is critically important to learn.

Can you make the namespace? The problem would be solved then too.
 

The topic of "purely virtual methods" was already raised on the forum a few years ago.

I.e. in C++ concept, virtual methods without a body that must MUST be overridden in descendants:

virtual void Func1() = 0;

In addition, a class containing such methods automatically becomes abstract. The compiler tracks this too. (Well, it's just to stick to the standards, though you may hide the constructor in a protected scope).

We are currently missing a lot of "pure virtual methods" behavior. Without such functionality, you can't properly prepare a library or framework to outsource it: you create your own child class (which is not just for nothing, but is embedded like a cog in other classes) and be kind enough to implement the whole interface. Now, you inherit, don't put in a method implementation, the compiler swallows it, nothing works. Digging through the source code of the parent class?

The concept of interface is one of the fundamentals of OOP. Therefore, I would really like to see the implementation of such a thing in 5, and not in MQL6

By the way, in the documentation on virtual functions, there is an error

Виртуальная функция, как и обычная функция, должна иметь исполняемое тело. При вызове семантика ее точно такая же, как и у остальных функций.

Example:

class Base {
private:
        int a;
public:
        virtual int Func1();
};


class Second: public Base {
public:
        int Func2() {
                return 0;
        };      
};

int OnInit() {

        Base* base = new Base();
        Second* foo = new Second();
   return(INIT_SUCCEEDED);
}

TheFunc1 virtual function has no executable body (and does not even return a value), but compiles without errors.

 
Igor Volodin:

The topic of "purely virtual methods" was already raised on the forum a few years ago.

I.e. in C++ concept, virtual methods without body, which must be MUST be overridden in descendants:

In addition, a class containing such methods automatically becomes abstract. The compiler tracks this too. (Well, it's just to stick to the standards, though you may hide the constructor in a protected scope).

We are currently missing a lot of "pure virtual methods" behavior. Without such functionality, you can't properly prepare a library or framework to outsource it: you create your own child class (which is not just for nothing, but is embedded like a cog in other classes) and be kind enough to implement the whole interface. Now, you inherit, don't put in a method implementation, the compiler swallows it, nothing works. Digging through the source code of the parent class?

The concept of interface is one of the fundamentals of OOP. Therefore, I would really like to see the implementation of such a thing in 5, and not in MQL6

By the way, in the documentation on virtual functions, there is an error

Example:

TheFunc1 virtual function has no executable body (and does not even return a value), but compiles without errors.

1. Pure virtual functions will be added soon

2. Where in your example is the Func1 call? No call - no body control.

 
Slawa:

1. Pure virtual functions will be added soon

2. Where's the Func1 call in your example? No call - no body control either.

VS 2015 said the following

Severity Code Description Project File Line Suppression State

Error LNK2001 unresolved external symbol "public: virtual int __thiscall Base::Func1(void)" (?Func1@Base@UAEHXZ) TestCPPCode C:\MyP\AvForex\trunk\TestCPPCode.obj 1

Error LNK1120 1 unresolved externals TestCPPCode C:\MyP\AvForex\trunk\MQL4FilesForFormatting2015\Debug\TestCPPCode.exe 1

 
Alexey Volchanskiy:

VS 2015 said the following

Severity Code Description Project File Line Suppression State

Error LNK2001 unresolved external symbol "public: virtual int __thiscall Base::Func1(void)" (?Func1@Base@UAEHXZ) TestCPPCode C:\MyP\AvForex\trunk\TestCPPCode.obj 1

Error LNK1120 1 unresolved externals TestCPPCode C:\MyP\AvForex\trunk\MQL4FilesForFormatting2015\Debug\TestCPPCode.exe 1

Show source code
Reason: