very confused on how to use vectors to display a matrix. Can any help with some code to start?
template<class t>class vector
not sure what to do after this?
HELP!!!!!
Printable View
very confused on how to use vectors to display a matrix. Can any help with some code to start?
template<class t>class vector
not sure what to do after this?
HELP!!!!!
Ok, I'm not sure what it is you wan't help with.. displaying the content of a vector? / a 2D vector? or just generaly how a vector works?
Here is a smal example:
#include <vector>
ostream& operator<<(ostream& out, const vector<int>& v) {
copy(v.begin(), v.end(), ostream_iterator<int>(out," "));
return out;
}
int main(void) {
// create a vector of double's, and one of int's
vector<int> vi;
// insert values before the beginning
for(int i = 0; i < 10; ++i) {
vi.insert(vi.begin(), i);
}
// print out the vector
cout << vi << endl;
return 0;
}
I'm not sure how to create a 2D(/matrix) vector .. perhaps this works:
vector<vector<sometype>> v;
- Anders