std::vector<std::vector<int> > maze;
char w;
for(int x = 0; x < this->mWidth; ++x){
//Should be doing something like creating a new vector...
//maze.push_back(what goes in here.. a new vector or.. ?)
for(int y = 0; y < this->mHeight; ++y){
input >> w;
//Putting w i there...
//maze[x].push_back(w); ?
}
}
I can't seem to wrap my head around it... it'd be so easy using a char**... Yet I have want to learn to use the STL so I need your advice
edit: template code doesn't play nicely with the [code] tag. Try using the [source] tag in the future.
[edited by - SiCrane on May 28, 2004 1:29:43 AM]
Vector of vectors, or, I suck at the STL
filling a vector of vectors with a maze... where mWidth is the width and mHeight is the height of the said maze. input being an ifstream.
Off the top of my head:
std::vector<std::vector<int> > maze; maze.resize(mWidth); for(int x = 0; x < mWidth; ++x){ maze[x].resize(mHeight); for(int y = 0; y < mHeight; ++y){ is >> maze[x][y]; } }
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement