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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:33:25+00:00 2026-05-25T10:33:25+00:00

I cannot explain myself the following code: double d = 100; double const d1

  • 0

I cannot explain myself the following code:

   double d = 100;

    double const d1 = 30;

    double* const p = &d; // Line 1
    double* const p1 = &d1; // Line 2

In the above code, Line 1 is ok, but Line 2 produces the error:

"error C2440: 'initializing' : cannot convert from 'const double *__w64 ' to 'double *const '"

Can anyone elaborate on that, please?
(I am using VS C++ 2005, running on Win XP SP3)

  • 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-25T10:33:25+00:00Added an answer on May 25, 2026 at 10:33 am

    The type double* const is a const pointer to a non-const double. If you want a pointer to a const double, you have to use double const* (or double const* const if you want a const pointer to a const double).

    In C++, with a simple pointer to a double, you the const-ness of both the pointer itself (ie, can you make it point at another location) and the const-ness of the value (can you change the value through the pointer) can be configured independently. This gives you four very similar, but incompatibles types:

    double const* const p1; // Const pointer to const double
                            //  . you can't have the pointer point to another address
                            //  . you can't mutate the value through the pointer
    
    double const* p2;       // Non-const pointer to const double
                            //  . you can have the pointer point to another address
                            //  . you can't mutate the value through the pointer
    
    double* const p3;       // Const pointer to double
                            //  . you can't have the pointer point to another address
                            //  . you can mutate the value through the pointer
    
    double* p4;             // Non-const pointer to non-const double
                            //  . you can have the pointer point to another address
                            //  . you can mutate the value through the pointer
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sorry folks but I asked a question earlier and perhaps did not explain myself
It's actually a noticeable difference that I've seen but cannot explain. These timers have
Cannot explain what is going on the following program. GetType is returning the type
Can someone explain to me why the following code compiles OK in Java? char
I cannot seem to debug my JavaScript code with Firebug. The play button is
I found something today in one of my databases that I cannot explain. I
for some reason I cannot explain, every single item in the character array...is equal
i cannot use sorting on join tables. Let me explain; i have three tables.
Could someone explain me why this code: class safe_bool_base { //13 protected: typedef void
I wouldn't describe myself as afraid of change - but afraid of new technologies?

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.