Array and pointer problem

I'm trying to debug a piece of code I was given and I'm uneasy with this:

Object** objects; (Object being a user-defined class)

I wanted to know if it was equivalent to this: Object* objects[] or more to this:
Object objects[][];

What I'm trying to know is if its an array of array or an array of pointer or something else.

nevero.
Last edited on
That depends very much on how you reserve the space for your objects and initialize your pointers.

For example:
1
2
3
int* single = new int; //Not an array.
//vs.
int* array = new int[5]; //Array. 


I used int* instead of int** for the example because the int** example is a lot more complicate- alright, whatever.
1
2
3
4
5
6
        int** arrayofpoints = new int*[5]; //1d array.
	int** pointtopoint = new int*; //Not an array.
	int** twodarray = new int*[5];
	for (int i = 0; i < 5; i++)
		twodarray[i] = new int[5]; /*2d array, by the end of the day.
If I messed something up and I might've because I'm half-concious, let me know.*/


I hope this helped you understand the insanity behind pointers.

-Albatross
Last edited on
Topic archived. No new replies allowed.