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

  • SEARCH
  • Home
  • 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 6088219
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:57:36+00:00 2026-05-23T11:57:36+00:00

So, my current understanding of enum is that I can use it to make

  • 0

So, my current understanding of enum is that I can use it to make constants that correspond to numbers. So,

typedef enum 
{
    number0 = 0,
    number1 = 1,
    .
    .
    .

} Numbers;

would allow me to refer to 0 as number0 in every part of the code. This seems to work fine. However, I’m having trouble figuring out how to use this in an Xcode Project. For example, say I write one class, NumberCounter, and include this code in the header file. Then, I write another class, numberCalculator. If I want to use the same definitions in the second class, do I have to A) write the classes in the same source file, or B) include the above code in every file I want to use the numbers?

If I include the code in one class, and exclude it in the second, I get (when trying to have a function return something of type Numbers) a Parse Issue Expected a Type error, but if I include the code in both, it gives an error about ‘Redefinition of enumerator’. Currently, my workaround is to include the code in every file, then use the preprocessor to make sure it is only executed once – i.e:

#ifndef NumberDef
#define NumberDef
typedef enum 
{
    number0 = 0,
    number1 = 1,
    .
    .
    .

} Numbers;
#endif

This works, but I feel like there should be a nice simple way of doing this. What am I missing here?

  • 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-23T11:57:37+00:00Added an answer on May 23, 2026 at 11:57 am

    Include the header it’s defined in.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My current understanding of Castle Windsor registration is that one can only validate registration
This is admittedly a rather loose question. My current understanding of singletons is that
Based on my current understanding of hashes in Perl, I would expect this code
My current understanding is that superviews have retains each of their subviews. For a
My current understanding is that I have to assign the coordinates in the code
So my current understanding of classes are: Singleton for a class that will only
I have come across a situation that conflicts with my current understanding of methods
I have been building a new application using my current understanding of domain driven
I'm considering picking up some very rudimentary understanding of assembly. My current goal is
I have been having a hard time understanding how to use a singleton to

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.