
Geek-Master
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 Posttypedef vector< vector< double > > matrix; typedef vector< double > row; matrix M; row R; /* Add some numbers to a row */ R.push_back( 1 ); R.push_back( 4 ); R.push_back( 2 ); /* Add the row to the matrix */ M.push_back( R ); // Repeat for …
All 18 Replies
Narue 5,707 Bad Cop Team Colleague

Geek-Master
Narue 5,707 Bad Cop Team Colleague
server_crash 64 Postaholic

Geek-Master
Narue 5,707 Bad Cop Team Colleague
saulocpp -1 Newbie Poster
Fbody 682 Posting Maven Featured Poster
saulocpp -1 Newbie Poster
Fbody 682 Posting Maven Featured Poster
servicecycle09 0 Newbie Poster
aayushssinghal 0 Newbie Poster
mrnutty 761 Senior Poster
Hialek 0 Newbie Poster
ravenous 266 Posting Pro in Training
raptr_dflo 48 Posting Pro
ravenous 266 Posting Pro in Training
Hialek 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.