Class Matrix { int dimension; vector<vector<int>> matrix; public: Matrix(int dimension); ... } Matrix::Matrix(int dimension) { this->dimension = dimension; } In the Matrix::Matrix(int dimension) method I want to set the dimension of a two-dimensional vector
dimension x dimension but the way i did it doesn't work
matrix.reserve(dimension); for (int i = 0; i < dimension; ++i) { matrix[i].reserve(dimension); }
std::vectoris not needed at all. IMHO, the most suitable of the standard ones here isstd::valarray. - αλεχολυτ