table = new myObject*[TABLE_SIZE];
I know that * are for declaring pointers variable and to obtain the value of the variable from a pointer, but what does this mean?
table = new myObject*[TABLE_SIZE];
I know that * are for declaring pointers variable and to obtain the value of the variable from a pointer, but what does this mean?
It means exactly that.
table
is a pointer to an array (with size TABLE_SIZE
) of pointers to objects of type myObject
. Note that you haven't allocated any memory for those pointers at this point.
Don't forget to call delete[] table;
once you're done with it.
This means that you allocate an array of type myObject*
of size TABLE_SIZE
.
So in this case we allocate space for the pointers but not the objects.
Your variable table
will then be a pointer to an array of pointers, or a myObject**
.
So table
will point to the first element in this list of pointers.
The asterisk means pointer here too. I am assuming that table
is declared like
myObject** table;
What you are doing is allocating an "array" of TABLE_SIZE
pointers to myObject
.
It means exactly what you already know it means :-)
The type myObject *
is a pointer to a myObject
object so what you are declaring is an array of said pointers, TABLE_SIZE
of them to be exact.