Lets say I do something like this
int *array;
array = new int[10];
How is memory set up for this array?
What type is array[0]? (a pointer? an int?)
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
This code first allocates room for a pointer called array. This memory is allocated on the stack.
Next, it allocates a block of memory from the heap to hold 10 integers and assigns the address to
array.array[0]will refer to the first integer in the block of 10. The subscript makes it a value instead of a pointer.And for God’s sakes, start accepting some answers that people are giving you!