Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4321438
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T08:44:46+00:00 2026-05-21T08:44:46+00:00

Say I create an enum but eventually someone wants to add items to that

  • 0

Say I create an enum but eventually someone wants to add items to that enum, what does one do?
ex:

// blah.hpp

enum PizzaDressing {
    DRESSING_OLIVES = 0,
    DRESSING_CHEESE = 1
};

and in my FunkyPizza class, there might be pepper toppings.

So how could I add peppers without obviously modifying the original enum?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T08:44:47+00:00Added an answer on May 21, 2026 at 8:44 am

    Since enums are typically handled as some size of int in the compiler, all you have to do is later make

    enum PizzaDressing
    {
        Olives = 0,
        Cheese = 1,
        Pepperoni = 2
    };
    

    or you could allow it to count

    enum PizzaDressing
    {
        Olives = 0,
        Cheese = 1,
        Pepperoni
    };
    

    You could, if neither of those is acceptable for some reason, use math (Cheese + 1).
    You can play around with the enum in almost any way you could with a numeric value.

    Note that the enumerator you use is typically baked into the code by the compiler, it doesn’t show up as its name, simply value. Thus, modifying (extending) the enumerator later on will not effect code that has been built.

    I think it’s legal syntax to use an enumeration in another enumerator, with casts, but I’ve never tried it. This may work, but is kind of ugly:

    enum PizzaDressing
    {
        Olives = 0,
        Cheese = 1
    };
    
    enum OtherPizzaDressings
    {
        Start = (OtherPizzaDressings)PizzaDressing::Cheese;
        Pepperoni
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say I create one object and add it to my ArrayList . If I
Say you create a form using ASP.NET MVC that has a dynamic number of
Let's say you create a wizard in an HTML form. One button goes back,
Let's say that I create a Sub (not a function) whose mission in life
There are other posts that say you can create a control in windows forms
This may be a stupid question but one that is throwing me for a
This is for Delphi Prism. Say, I have the following enum SET type that
Let's say we've defined a postgresql type: CREATE TYPE my_type AS ENUM('foo', 'bar'); Is
The instructions say: Create an equals method that takes an object reference and returns
Say I create an object thus: var myObject = {ircEvent: PRIVMSG, method: newURI, regex:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.