I am new to c++ programming and trying to understand this syntax
int **arr;
arr = new int *[5];
I am confused about this part new int *[5]; Does it mean pointer of type int to 5 subpointers?
Any help will be appreciated.
This will hopefully become clear when you read it piece by piece:
new int * [5]
^^^ ^^^^^ ^^^
give me pointers to int and five of those.
Then you safe the address of the first of the new pointers in arr and thus have an dynamically allocated array of five pointers.
Note that "in the real world" (i.e. if no teacher/prof forbids you to) you would use an std::vector instead of new[].
Does it mean pointer of type int to 5 subpointers?More like a pointer of type "int pointer", and a 5 element array with that.