C++ How to dynamically create a 2D vector

前端 未结 3 2007
陌清茗
陌清茗 2021-01-27 00:14

I\'m trying to create an n x n vector that I can later cout as a table/matrix. Xcode points to the = in the for loop and tells me No

3条回答
  •  时光取名叫无心
    2021-01-27 01:00

    When the constructor of row is called, all elements are initialized too. I think this code does what you're looking to do:

    for (int i=0; i

    Now all elements of row will be of size n.

提交回复
热议问题