Is this Correct?
No. Mixing new
and malloc()
is not a good idea.
If you must use dynamic memory allocation, then read this: How do I declare a 2d array in C++ using new?
Otherwise, use an std::vector
.
12
solved c++ : An array of the pointer float type with dynamic size