Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.
Trending News
What does double **a mean in C++?
What do the 2 asterisks in front of 'a' mean?
double **a;
a=new double*[m];
for (int i=0;i<m;i++)
a[i]=new double[n1];
4 Answers
- husoskiLv 78 years ago
One * means a pointer. Two means a pointer to a pointer, and so on. In this case, a points to not just one pointer, but an array of m pointers. And each pointer in that array points to a double. In this case, not just one double but an array of n1 of them.
When the for loop is done, you'll have a dynamic two-dimensional arrays where a[i] is a pointer to the the (i+1)th array of doubles and then a[i][j] is the (j+1)th double in that array. (0 <= i < m and 0 <= j < n1)
- aha123555Lv 48 years ago
Understand this with the below example:
int i = 200; // Creating a variable i, where we are storing 200 and also lets assume that the memory location allocated to store i is location address 400 to 403, as int is 4 bytes.
int* p = &i; //Here we are creating a pointer variable whose name is p, which can store an address of a integer variable. hence from the above, the value stored in p is 400. And here lets assume that the address where p is stored is 800 to 803, as pointer will take 4 bytes of memory space.
// Now if you need to store the address of a pointer variable, you will create a double pointer, as:
int** p1 = &p; // Here p1 stores the value 800.
- RatchetrLv 78 years ago
Lets not use a as the variable name, because it makes it confusing to explain in words (since a is also a word).
Assume it was double ** pd;
Then:
pd is a pointer to a pointer. The pointer that pd points to is a pointer to a double.
pd ---> somepointer ---> somedouble
What is allocated by new is an array of pointers to double. pd is a pointer to this array, so it points to the first element in the array, which is a pointer to a double. So pd points to a pointer to a double.
- 8 years ago
That denotes that a is a pointer to a pointer. Its just another level of referencing.
This program is creating a pointer (a) to a pointer array of pointers to double. Most likely you will return a reference to 'a' later in your program assuming this is a function that returns a pointer to double.
double 'a' represents a pointer to the array 'a'. Array 'a' contains pointers to double.