Original Post
Im trying to get a decent way to render all my OO classes. Using one of the Columns on this site I implemented this code(its not the TOTAL code, but it should be enough for someone to point out what im doing wrong)
The problem is that my iterator in Render::updateScene always asserts and i dont know what is the matter.
Any help is appreciated
[edited by - useful on June 7, 2002 5:36:42 PM]
[edited by - useful on June 7, 2002 5:37:53 PM]
class Object
{
public:
Object() {}
~Object() {}
void addChild(Object* pChild)
{
assert(pChild);
pChild->setParent(this);
children.push_back(pChild);
}
std::vector<Object*>* getChildList()
{
return &children
}
protected:
std::vector<Object*> children;
GameObject* parent;
private:
void setParent(Object* pParent)
{
parent = pParent;
}
};
void Render::updateScene(Object* pObject)
{
// Base case for the recursion
if (pObject == NULL)
return;
else
{
pObject->update();
pObject->draw();
// begin problem code
std::vector<pObject*>::iterator it = pObject->getChildList()->begin();
assert(it);
while (it != pObject->getChildList()->end())
{
updateScene(*it);
}
// end problem code
}
}