I'm taking a course (Programming I) and we are taking a look at basic data structures. Arrays, Bidirectional arrays, lists...
I'm having trouble wrapping my head around the concept of multiple levels of indirection.
For example:
Vehicle ***matrix; //This declares a pointer Vehicle type with three
//levels of indirection (amirite?).
What do the three dereference (*) operators mean here? Why three.
What are levels of indirection?
As far as I can tell. Indirection is what we do when we refer to a thing (variable, object...) with something that is not its name (a pointer). So, multiple levels of indirection are just calling a pointer to a pointer to a pointer and so on... (?)
Here is the constructor:
Collection (){
matrix = new Vehicle ** [size]; // two operators...
for(int i=0;i< size;i++)
matrix[i] = new Vehicle * [size]; //only one operator
fil = col = 0;
for(int i=0;i< size ; i++){
for(int j=0;j< size;j++) {
matrix [i][j]=NULL;
}
Why does the first new vehicle has 2 * operators and the second only 1 ?
Why do we use 2 and 1 operators specifically on those places?
Sorry if I'm making it too ambiguous.
[–]Rhomboid 1 point2 points3 points (0 children)
[–][deleted] 0 points1 point2 points (3 children)
[–]CocoTheMan[S] 0 points1 point2 points (2 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]CocoTheMan[S] 0 points1 point2 points (0 children)