I know that the common technique of creating a dynamic array in C++ is:
int * arr = new int;
short tell; // tell an array of 20 bytes
cout << tell << endl; // displays &tell
cout << &tell << endl; // displays address of the whole array
short (*p) = &tell; // p points to an array of 20 shorts
int (*p) = new int;
int (*p1) = (int (*)) new int;
cout << "sizeof(*p1) = " << sizeof(*p1) << endl;
int * p2 = new int;
cout << "sizeof(*p2) = " << sizeof(*p2) << endl;
know that the common technique of creating a dynamic array
In C++ that was written 20 years ago, maybe.
These days you should use
std::vector for dynamic arrays and
std::array for fixed size array.
If your framework or platform supplies additional array classes (like QT's
QVector), they are fine too, as long as you don't mess with C-pointers directly, and you have RAII-based array class.
and as for concrete answer,
new T[size] always returns
T* , so you cannot catch a pointer returned by