-
September 22nd, 2010, 08:43 AM
#1
pointer confusion ~.~
Hy can somone pls explain me what the type(like int) **name is... i figure that *is a pointer... but what is **?????
Last edited by sangoku; September 22nd, 2010 at 08:47 AM.
-
September 22nd, 2010, 08:49 AM
#2
Re: pointer confusion ~.~
"ref class"? I don't know what the ref keyword means. Is this native C++?
Second, I don't see any reason to be using dynamic allocation if you're always going to allocate to the same size anyway....just make the member be
int stubovi[3][10];
to begin with. Working with pointers directly in a class or struct definition introduces complications such as the need to define the copy constructor and operator= explicitly.
Third, the most likely cause of an error on an array access is the index being invalid. What is saStuba?
Fourth, even if saStuba is a valid index (0,1, or 2 in this case), the type of stubovi[saStuba] will still be int*, so you won't be able to assign to an int.
-
September 22nd, 2010, 10:57 AM
#3
Re: pointer confusion ~.~
Originally Posted by sangoku
Hy can somone pls explain me what the type(like int) **name is... i figure that *is a pointer... but what is **?????
the double star implies that its a double pointer, and further allocation may be done
int variable = 3;
int variable2 = 5;
Code:
int **pointer = new int * [variable];
for (int i=0; i<variable; i++)
{
pointer[variable] = new int[variable2];
}
Last edited by dchaacke; September 22nd, 2010 at 11:16 AM.
Reason: corrected information
-
September 22nd, 2010, 11:01 AM
#4
Re: pointer confusion ~.~
Originally Posted by dchaacke
the double star implies that further allocation will be done
Well no, it only implies it's a pointer which happens to point to another pointer. Often this will indicate further allocation is done, but not always.
-
September 22nd, 2010, 11:16 AM
#5
Re: pointer confusion ~.~
Originally Posted by Lindley
Well no, it only implies it's a pointer which happens to point to another pointer. Often this will indicate further allocation is done, but not always.
my mistake, i have edited my post.
-
September 24th, 2010, 07:19 AM
#6
Re: pointer confusion ~.~
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|