Re: [Dev-C++] conversion of double pointers
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
From: Per W. <pw...@ia...> - 2008-07-18 00:04:55
|
There is no limitation on double pointers. This is a limitation in your understanding of the const keyword, and what it binds to. You can have a const pointer, i.e. a pointer that may not be changed to point at a different double. You can have a pointer to a const value, i.e. you may not assign a new double value using the pointer. And you can have a const pointer to a const double, in which case neither the value of the pointer, or the value that the pointer points to may be changed. When you add a second indirection (pointer to pointer to double) you just get one more position where you can add your const, i.e. if the first pointer level allows you to change the the value of the second-level pointer. You should get the C++ standard, and look at the rules regarding const, and regarding pointer declarations. /pwm On Wed, 16 Jul 2008, Dick Kopcke wrote: > I am running Dev-Cpp 4.9.9.2 > The following generates an error at the function call: > invalid conversion from 'double**" to 'const double**' > > The program runs if the 'const double**' is changed to 'double**' in the function definition. > Conversions such as 'double *' to 'const double*' in the function pose no problems. > > This limitation on double pointers surprises me. What should I be doing differently? > > Thanks > > > > void Multiply(const > double** const M, const double * const V, > > const int n, const int m, double > * const MV) > > { > > code > > } > > > > int main() > > { > > > > code > > > > double** Matrix = > new double* [n]; > > for (int i=0; > i<n; i++) Matrix[i] = new double [m]; > > > > code > > > > Multiply(Matrix, Vector, n, m, MVproduct); > > > > code > > } > > > > > > > |