Am I reading this right? such as an array of pointers, or an a pointer to 300pointer
Hello everyone!
I was just curious if i'm reading this right? My C++ professor, said, create a function to accept an array of pointers, now if i had
void (int *x);
and inside the function i wrote,
x = new int[300]; I understand that this creates 300 memory locations on the heap, so really its creating an array, and x is pointing to the first element of the array right?
because x is really &x[0];
now if i would have wrote:
void (int*x[]); is this what he really wanted? I thought this would be a pointer to a pointer, becuase isn't like that like
void (int **x); or am i confusing myself?
I remember I came across this nice tutorial that tells you how to approach such problems, but I lost it! :(
Thanks for listening!
Also he said, make a class cubes, then make an array of 300 cube objects, are these equivlent other then one being on the heap and one being on the stack?
Cube * cubes[300]; //an array of 300 pointer objects
Cube * cubes = new Cube[300]; //a pointer pointing to 300 cube objects