CreateWnd()
{
...
CGUIWnd wnd = CGUIWnd(idwnd,x,y,w,h);
m_aWnds.push_back(wnd);
CGUIButton button = CGUIButton(idbutton,m_aWnds.back(),x,y,w,h);
m_aButtons.push_back( button );
...
}
What happens? I create a window and than a button. The window are registered as the parent for the button.
CGUIButton is derived from CGUIWnd. In the CGUIButton class I have a pointer to a CGUIWnd (that is the parent of the button).
This works fine first time the function is called but when the second window is created the first button (the button on the window) get crap values! Something happens when the vector object m_aButtons inserts a new element to the list.
I think it is because of the CGUIWnd pointer in the CGUIButton class. When a new element is inserted in m_aWnds the pointer in CGUIButton class isn´t valid anymore.
Please help!
Zeblar Nagrim, Lord of Chaos
vector list problem
Hello,
I have problems with the std::vector class:
With the limitted code you''ve put here, it appears that your problem is in the definition of your vector. It looks like you''re defining a vector of objects, not pointers, and pushing-in derived class objects. This will not work. In order to use polymorphism in STL containers you have to use pointers (or smart pointers), not objects.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement