Code: Select all
// if we were given a parent to attach to
if (parent)
{
parent->addChildToEnd(this);
recalculateAbsolutePosition(true);
}
Code: Select all
// if we were given a parent to attach to
if (parent)
{
parent->addChildToEnd(this);
recalculateAbsolutePosition(true);
}
Code: Select all
#include <iostream>
class Base
{
public:
Base()
{
Foo();
}
virtual void Foo()
{
std::cout << "Base\n";
}
};
class Derived : public Base
{
public:
virtual void Foo()
{
std::cout << "Derived\n";
}
};
int main()
{
Derived d;
return 0;
}
I believe that this is the problem. Rather than telling the parent to add child from the childs constructor, doing it from a higher level makes more sense. This sounds like a good solution.I suspect the real problem here is that adding/removing elements should not happen at all in the IGUIElement and ISceneNode classes but rather in IGUIEnvironment and ISceneManager.