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;
}