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
The simple solution is to use the relevant constructor of std::vector, initializing it to n
elements each having the value of val
- no loops necessary.
std::vector (n, val);
Having your original snippet we would end up with the following, which will initialize row to have n
std::vectors, each of which having n
elements.
std::vector > row (n, std::vector (n));