I\'m using the vector class in the STL library for the first time. How should I add to a specific row of the vector array?
struct x{
vector
Just use the following methods to create a 2-D vector.
int rows, columns;
// . . .
vector < vector < int > > Matrix(rows, vector< int >(columns,0));
OR
vector < vector < int > > Matrix;
Matrix.assign(rows, vector < int >(columns, 0));
//Do your stuff here...
This will create a Matrix of size rows * columns and initializes it with zeros because we are passing a zero(0) as a second argument in the constructor i.e vector < int > (columns, 0).