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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T05:23:15+00:00 2026-06-03T05:23:15+00:00

What are the differences between int a; // a gets some value double pi

  • 0

What are the differences between

int a;
// a gets some value
double pi = static_cast<double>(a)/3;

and

int a;
// a gets some value
double pi = double(a)/3;

Have you ever seen the latter? It seems to me I saw it in some snippet written by Stroustrup but I can’t find the reference.

  • 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-03T05:23:16+00:00Added an answer on June 3, 2026 at 5:23 am

    Someone may have thought they were constructing rather than casting. Consider:

    some_fun(std::string("Hello"));
    

    Many people think they’re calling a constructor there when in fact they’re doing a C-style cast. It just so happens that casting will look at constructors of the target type among the long list of other things it looks at and so here it eventually ends up invoking the constructor.

    Functional notation casts have all the same weaknesses of the other kind of C cast:

    • Can inadvertently cast away constness
    • Can silently turn into a reinterpret cast
    • Are hard to differentiate with grepping tools.

    Besides all that though, you’re performing exactly the same operation in both cases.

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

Sidebar

Related Questions

Can you help me understand the practical differences between these two; IList<int> myList =
What are the differences between int size = (int)((length * 200L) / 100L); //
Possible Duplicate: What are the differences between using int[][] and int[,]? I just came
What are some of the technical differences between memory that is allocated with the
I'm a Python newbie. I have been a little confused by the differences between
I have been reading about the differences between Table Variables and Temp Tables and
I have some code that gets two Time Picker's content and displays them individually
In C++ specifically, what are the semantic differences between for example: static const int
Is there any difference between int on_exit(void (*function)(int , void *), void *arg); and
What is the main difference between int.Parse() and Convert.ToInt32() ? Which one is 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.