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

前端 未结 9 1110
北海茫月
北海茫月 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:22

    It may be possible to store multi-dimensional data in a single-data array, but you have to keep track of the indexes yourself. Multi-dimensional arrays are actually stored in memory as a single dimensional array, with syntax to support representing that data as multi-dimensional.

    If you are working with multi-dimensional data, then I feel it is most appropriate to choose the correct tool for the job (a multi-dimensional array).

提交回复
热议问题