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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:21:15+00:00 2026-06-14T20:21:15+00:00

I am trying to learn C++ and I’m having some difficulties learning pointers and

  • 0

I am trying to learn C++ and I’m having some difficulties learning pointers and references. I’m trying to understand why some of the below do not work, and I cannot seem to figure out the difference between “double *const ptd” and “const double *ctd”

double d;
  const double r; //bad; r must be initialised
  const double pi = 3.1416;
  double *ptr = π //illegal to point to a constant, because otherwise one could change the value of the constant which defies the purpose of a constant
  double *const cpt; //bad; cpt must be initialised
  double *const ptd = &d;
  const double *ctd = &d;
  const double *ptc = π
  double *const ptp = π //illegal
  const double *const ppi = π 
  double * const * pptr1 = &ptc;
  double * const * pptr2 = &ptd;

  void F () {
    ptr = new double;
    r = 1.0;
    *ptr = 2.0;
    cpt = new double;
    *cpt = 3.0;
    ptc = new double;
    *ptc = 4.0;
    ptd = new double;
    *ptd = 5.0;
    ctd = new double;
    *ctd = 6.0;
    ptp = new double;
    *ptp = 7.0;
    ppi = new double;
    *ppi = 8.0;
  }
  • 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-14T20:21:16+00:00Added an answer on June 14, 2026 at 8:21 pm

    double * const (read as “constant pointer”) means that the pointer is constant. You can’t modify it, but you can change the object that it points to.

    const double * or double const * (read as “pointer to constant”) means that the pointer can’t be used to change the object it points to; but the pointer itself can be modified.

    In general, the const qualifies the thing immediately before it; or the first thing, if there’s nothing before it.

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

Sidebar

Related Questions

trying to learn some html/css and I'm having a problem with fixed position divs.
Im trying to learn obj-c and here's something I dont understand. I know some
Trying to learn Sencha Touch 2 and I can't seem to find out how
im trying to learn delegates and events in c#, i understand that an event
Im trying to learn a bit about c++ and have run in to some
Trying to learn some R after doing mostly Haskell for rather a long time
Trying to learn some F# and I've run into a couple of hangups. Here's
I'm trying to learn some basics of Ruby on Rails and encountered a problem
im trying to learn how to use javascript objects, and got some issue here.
Im trying to learn class-based views, for a detail or list view is not

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.