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 6201023
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T04:28:38+00:00 2026-05-24T04:28:38+00:00

There are sort of two related questions here: A) How is enum implemented? For

  • 0

There are sort of two related questions here:

A) How is enum implemented? For example, if I have the code:

enum myType
{ 
   TYPE_1,
   TYPE_2
};

What is actually happening? I know that you can treat TYPE_1 and TYPE_2 as ints, but are they actually just ints?

B) Based on that information, assuming that the enum passed in didn’t need to be changed, would it make more sense to pass myType into a function as a value or as a const reference?

For example, which is the better choice:

void myFunction(myType x){ // some stuff }

or

void myFunction(const myType& x) { // some stuff }
  • 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-24T04:28:39+00:00Added an answer on May 24, 2026 at 4:28 am

    Speed wise it almost certainly doesn’t matter – any decent C++ compiler is just going to pass a single int.

    The important point is readability – which will make your code more obvious to the reader?

    If it’s obvious that these enums are really just ints then I would pass them by value, as if they were ints. Using the const ref might cause a programmer to think twice (never a good idea!)

    However – if you are later going to replace them with a class then keeping the API the same and enforcing the const-ness might make sense.

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

Sidebar

Related Questions

I guess this is sort of two questions that are tied together. Related questions
I have two questions about creating thread safe types in python, and one related
Is there some sort of formatting protocol for html email? We have an automated
Is there any way to sort alphabetically two strings variables in a JSP, for
There were few questions related to this but none answered the question in my
In a web app which I'm building, I have two loosely related bits of
Is there any sort of free control which does what the Occupation field does
Is there some sort of profiling tool available? View source and search/replace?
Is there some sort of built-in authentication in WCF? I need to expose a
Is there any sort of out of the box system within SharePoint (i.e. MOSS

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.