Reputation: 131
_classA **_TTT[3];
_TTT[n][_num_ttt[n]] = new _classA(3,5);
May I know what is
_TTT[n][_num_ttt[n]]
How this dynamic array work?Appreciate if you could provide me an explanation in graphical view how actually the dynamic pointer point to the other and how to form [ ][ ]. Thanks.
Upvotes: 0
Views: 78
Reputation:
Czech this Tutorial on MultiDim Arrays, it might bring some light into that dark room of yours.
But basically you just store an array of arrays. Arrays are nothing more than an collection of pointers to data points. In C++ you can have pointers pointing to other pointers which then again point to the value.
Rather don't use it, except if you really need it, as many programmers really get confused by it quickly. One Application would be a Map or Picture, where you need X/Y coordinates, but except that you can do things simpler by other methods.
Upvotes: 1
Reputation: 2273
_TTT
is a static array of three pointer-to-pointers-to-classA.
_TTT[n]
gives us one of the pointer-to-pointers, _num_ttt[n]
is just another index (like i would be) so, _TTT[n][i]
finally resolves to the i'th pointer to _classA inside the n'th array of pointers. It is then assigned with the new
on the right side.
Upvotes: 2