See one of my earlier posts for another topic related to vectors of pointers.
However, after committing a cardinal sin of modifying source code without making a copy, I was left with completely buggered file I/O code.
Essentially I'm working with a vector of pointers to a class. I've watered it down to bare essentials to give you the gist:
Code: Select all
class MapObject : public Object { // the inheritance isn't important, not all game objects are map objects
...
private:
int x;
int y;
int layer;
...
};
class Map {
void write_map(vector<MapObject*> mapObjs);
void read_map(vector<MapObject*> mapObjs);
};
Code: Select all
Map::write_map(vector<MapObject*> mapObjs)
{
mapFile.open(fileName.c_str(), ios::binary | ios::out);
mapFile.write(...); // this is the sticky part
mapFile.close();
}
So that leaves me with the idea that I'll need to iterate through all the map objects in the vector to write them out. I worked on that for a few hours but caused more harm than good. Does anyone have any pointers (pardon the pun)?
-capt jack