Three dimensional arrays of integers in C++

前端 未结 7 1572
野的像风
野的像风 2020-12-17 00:05

I would like to find out safe ways of implementing three dimensional arrays of integers in C++, using pointer arithmetic / dynamic memory allocation, or, alternatively using

7条回答
  •  半阙折子戏
    2020-12-17 00:09

    With vectors:

    std::vector< std::vector< std::vector< int > > > array3d;
    

    Every element is accessible wit array3d[x][y][z] if the element was already added. (e.g. via push_back)

提交回复
热议问题