Recommended Answers
Jump to Post#include <vector> std::vector<std::vector<T> > mat;
Jump to PostNo, you're working with vector objects, so if you want to set the size beforehand, you do it with a constructor:
#include <iostream> #include <iomanip> #include <vector> using namespace std; int main() { vector<vector<int> > items ( 5, vector<int> ( 5 ) ); int k = 0; …
Jump to PostNot that it's important or anything, but you can initialize all the elements to a specific value:
vector< vector< double > > matrix( row, vector<double>(row, int_val));
Jump to Post>Is there not that much support for 2D or 3D vectors?
Any compiler that claims to implement C++ must support vectors of vectors for a suitable number of dimensions. The syntax can be awkward, so most people end up using wrapper libraries such as boost::multi_array rather than coding it by …
Jump to PostI'd like to bump this old thread since 2d arrays are a huge problem for the majority of C/C++ programmers. If one needs the array to be dynamic, the nightmare is there.
This page has good explanations:
All 18 Replies
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.