How to make a multi vector in C++
Posted
by
Bob Dealio
on Stack Overflow
See other posts from Stack Overflow
or by Bob Dealio
Published on 2012-03-27T23:05:15Z
Indexed on
2012/03/27
23:29 UTC
Read the original article
Hit count: 136
c++
I was wondering why can't I have a multi vectors in C ++ /please take a look at this example, it's not working though.
there are only two parts to the code, foo function to manipulate the vector and the main function to echo them.
typedef vector< vector<double> > MyVec;
MyVec foo() {
MyVec v;
for (int index=0; index < 2; index ++) {
for (int j=0; j<5; j++) {
v[index][j];
}
}
return v;
}
int main () {
MyVec z = foo();
for (int i = 0; i < z.size(); i++) {
cout << z[i][1];
}
return 0;
}
© Stack Overflow or respective owner