How to initialize 3 dimension vector with the size in C++

后端 未结 2 1714
轮回少年
轮回少年 2020-12-25 08:19

For example, if we initialize vector>> f, the dimension in each direction is not specified. So, I am wondering, what com

相关标签:
2条回答
  • 2020-12-25 09:06
    vector<vector<vector<double>>> f(3, vector<vector<double>>(4, vector<double>(5)));
    
    0 讨论(0)
  • 2020-12-25 09:10
    std::vector<std::vector<std::vector<double>>> f(3, std::vector<std::vector<double>>(4, std::vector<double>(5,0.0)));
    

    For anyone who wants it without namespace std. Also the values in this f[3][4][5] are initialised to 0.0 which might be useful.

    0 讨论(0)
提交回复
热议问题