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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:26:17+00:00 2026-06-13T11:26:17+00:00

If I remember right a C-Style conversion is nothing more than an ordered set

  • 0

If I remember right a C-Style conversion is nothing more than an ordered set of conversions static_cast, dynamic_cast, reinterpret_cast, static_cast...,
consider:

enum NUMBERS
{
    NUMBER_ONE,
    NUMBER_TWO
};

void Do( NUMBERS a )
{
}

int _tmain(int argc, _TCHAR* argv[])
{   

    unsigned int a = 1;
    Do( a ); //C2664
    return 0;
}

a C-Style conversion would do

Do( (NUMBERS)a );

What I would like to know is, what is the correct non C-Style conversion to be made, why?

  • 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-06-13T11:26:18+00:00Added an answer on June 13, 2026 at 11:26 am

    The correct way would be:

    static_cast<NUMBERS>(a)
    

    Because:

    8) Integer, floating-point, or enumeration type can be converted to
    any enumeration type (the result is unspecified if the value of
    expression, converted to the enumeration’s underlying type, is not one
    of the target enumeration values)

    Source: http://en.cppreference.com/w/cpp/language/static_cast

    dynamic_cast does runtime checks using RTTI, so it only applies to classes with at least one virtual method.

    reinterprest_cast is designed to tell the compiler to treat a specific piece of memory as some different type, without any actual runtime conversions.

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

Sidebar

Related Questions

Do I remember right or the parameter immediate set to true should change the
I remember Google says we should always use the latest API and set the
I cant remember the right aproach in php to sort data from related tables
I remember seeing a tutorial somewhere that talks of how to style your input
While, as far as I remember, IEEE 754 says nothing about a flush-to-zero mode
I have an image that is around 1200 x 400 (if I remember right),
If I remember right, a double or float is broken into 3 parts: a
Remember imagemaps? They were all over the place in the 90s. A webpage would
I remember the days (not too long ago, really) when log4net came along with
I remember a few months ago finding a very short (three methods, IIRC) but

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.