Pointer-to-pointer dynamic two-dimensional array

后端 未结 5 1791
庸人自扰
庸人自扰 2020-11-28 03:56

First timer on this website, so here goes..

I\'m a newbie to C++ and I\'m currently working through the book \"Data structures using C++ 2nd ed, of D.S. Malik\".

5条回答
  •  無奈伤痛
    2020-11-28 04:27

    In both cases your inner dimension may be dynamically specified (i.e. taken from a variable), but the difference is in the outer dimension.

    This question is basically equivalent to the following:

    Is int* x = new int[4]; "better" than int x[4]?

    The answer is: "no, unless you need to choose that array dimension dynamically."

提交回复
热议问题