Is it bad practice to use multi-dimensional arrays in C/C++?

前端 未结 9 884
北海茫月
北海茫月 2021-02-07 04:46

Some programmers seem to violently hate them, while others seem to think they\'re fine. I know that anything that can be done to a multi-dimensional array can also be done to a

9条回答
  •  礼貌的吻别
    2021-02-07 05:33

    Well, in C++ I dislike multidimensional arrays because they should be replaced with std::vector >. They're also particularly important if you want to represent a std::vector >.

    Multidimensional arrays are so simple a primitive I'm suprised most would care. However, a design that uses a single dimension is probably better than one using multiple dimensions, all other things being equal.

提交回复
热议问题