Code: Select all
class MapObject {
public:
int get_x(); // method implementation is obvious so i'll spare you the details
int get_y(); // ditto
...
private:
int x;
int y;
...
};
Code: Select all
class Map {
public:
void map_debug();
...
private:
vector<MapObject*> mapObjects;
...
};
void Map::map_debug()
{
...
for (vector<MapObject*>::iterator i = mapObjects.begin(); i != mapObjects.end(); i++)
dbg.Print("(x, y) = (%d, %d)\n", i->get_x(), i->get_y()); // thanks gyrovorbis for debug singleton vid
}
Code: Select all
error C2839: invalid return type 'Object **' for overloaded 'operator ->'
error C2039: 'get_x' : is not a member of 'std::_Vector_iterator<_Ty,_Alloc>'
Code: Select all
void Map::map_debug()
{
...
for (unsigned int i = 0; i < mapObjects.size(); i++)
dbg.Print("(x, y) = (%d, %d)\n", mapObjects[i]->get_x(), mapObjects[i]->get_y());
}
Why the hell can I not use the idiomatic vector<MapObject*>::iterator? I get the feeling that I'm not redirecting a pointer correctly, but I'm baked.
-capt jack