I am using the MT4 enumeration for a selection input:
enum ENUM_myChoice { a, b, c, e, f, g };
The problem is if I have to add "d" to the list in alphabetical order, all of my templates using e, f or g are ruined because they are off by 1.
Is there an elegant solution to this or only brute force?
Thanks in Advance
Avery Horton: The problem is if I have to add "d" to the list in alphabetical order, all of my templates using e, f or g are ruined because they are off by 1.
| Keep the numeric values constant, add new values alphabetically. enum ENUM_myChoice { a, b, c, d=6, e=3, f, g }; | ||||
Alain Verleyen: Ruined, why ? you used the numerical value ? | A template stores numeric values
|
I am using the MT4 enumeration for a selection input:
enum ENUM_myChoice { a, b, c, e, f, g };
The problem is if I have to add "d" to the list in alphabetical order, all of my templates using e, f or g are ruined because they are off by 1.
Is there an elegant solution to this or only brute force?
Thanks in Advance
If I needed to insert a member and not to affect the previous declaration, I would assign a value to each member.
enum ENUM_myChoice { a=1, b=2, c=3, e=4, f=5, g=6 };
enum ENUM_myChoice { a=1, b=2, c=3, d=7,e=4, f=5, g=6 };
If I needed to insert a member and not to affect the previous declaration, I would assign a value to each member.
enum ENUM_myChoice { a=1, b=2, c=3, e=4, f=5, g=6 };
enum ENUM_myChoice { a=1, b=2, c=3, d=7,e=4, f=5, g=6 };
Thank you.
That should fix it!
| Keep the numeric values constant, add new values alphabetically. enum ENUM_myChoice { a, b, c, d=6, e=3, f, g }; | ||||
A template stores numeric values
|
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I am using the MT4 enumeration for a selection input:
enum ENUM_myChoice { a, b, c, e, f, g };
The problem is if I have to add "d" to the list in alphabetical order, all of my templates using e, f or g are ruined because they are off by 1.
Is there an elegant solution to this or only brute force?
Thanks in Advance