You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
ME5 gives an error when compiling, in my opinion unwarranted.
I would like the predefined enum of the form ENUM_XXX to actually be numbered 1, whereas currently it is numbered by default, i.e. 0. The question is not about changing the defaults, but about replacing
it should be
The reasoning is as follows - an example:
When I analyze request.type value somewhere in code, if it equals 0, I cannot understand whether it was not initialized or was initialized.
request.type = ORDER_TYPE_BUY;
This is the case with most of the predefined enums of the form ENUM_ XXX equivalent of RadioButton and requires an unreasonable amount of complexity to correctly handle the current situation
What prevents you from writing a neutral identifier as the first member of a predefined enumeration? For example:
Both "numbering from zero" will be preserved, and uninitialized variables can be easily evaluated.
What prevents you from writing a neutral identifier as the first member of a predefined enumeration? For example:
And if you think about the others who are already using the original set of enums? This is not to mention the perplexed look from the entire server complex.
In general, the question is not posed correctly. The developer should not be lazy and force the rest of the world to fit in by self-destructing that very world.
Well, let's think again, "about the rest". What are named constant identifiers for? - Correct, in order to use these identifiers. Moreover, to use these identifiers, you do not need to know what specific values are assigned to enumeration members. Or do you assume that competent programmers use identifiers instead of finding out the default values of enum members, and then make checks based on these default values?
I.e., it's not hard to implement the suggestion itself, is it?
The author of this thread didn't intend to destroy other people's worlds through his laziness. He only made a specific suggestion for improvement. And explained that the zero value turns out to be overloaded.
I would like to introduce at least a class as the scope for enum-named elements,
Rationale for Classes: you have to come up with a unique name that may unexpectedly conflict with library (including third-party) and/or predefined names. Besides, you could use similar names of SL, TP, PRICE, etc. enum elements in several classes simultaneously without fear of conflicts.
Rationale for functions: not critical, but at the same time
We would like to introduce a scope for enum-named elements
Rationale for Classes: you have to come up with a unique name that may unexpectedly conflict with a library and/or predefined name. Also, you could use similar names for SL, TP, PRICE, etc enum elements in several classes at the same time without fear of conflicts.
Rationale for functions: not critical, but at the same time
But what's it like in C++ ?
That's where the legs come from - a paradox, but only now (when there are restrictions), I began to understand why everything was done there :)
Of course, you could do without it - to write a unique name for all classes, but for large programs, and especially for libraries intended for general use - is not an option
Try this (for "initialisation"):
WRONG_VALUE.
A constant can be implicitly cast to any enum type.
-1