Jump to content
  • Advertisement
Sign in to follow this  
donjonson

is it possible to make a dynamic enumerated list?

This topic is 4879 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Say I have an enumerated list and sometime later in the code I want to add another item to the enumerated list. is this possible? if so how would i go about doing this?

Share this post


Link to post
Share on other sites
Advertisement
Counter-questions:

What language?

What does your list currently look like? How do you define it and use it currently?

Share this post


Link to post
Share on other sites
C++

I have not yet created this list or used it.


but this is how I would create it

enum myEnumList{ me, you, he, she};

//say later I wanted to add them to the list could I do it?

Share this post


Link to post
Share on other sites
Unless there is some trick I do not know about you will have to create your own class for doing this, probably two classes. One which will act as the changing list of values and another which will hold a value and can be compared to another dynamic enum instance.

Share this post


Link to post
Share on other sites
Not to my knowledge.

Personally, I don't use enums much anymore for this sort of reason. Most of the places I would've used enums I now use a hash_map [not standard, but comes with modern gcc, and many others I hear; directly or within a class] to do that "meaningful name to unique id" work. Plus, this way I can go back from the id to the name [edit: more] easily and store definition sort of information with the string/id pair.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!