I'm trying to learn wxWidgets, but I'm stuck on a point which I can't find an explanation for anywhere in the documentation. I am trying to understand this minimal wxWidgets program:
#include <wx/wx.h>
class MyApp : public wxApp
{
virtual bool OnInit();
};
IMPLEMENT_APP(MyApp)
bool MyApp::OnInit()
{
wxFrame *frame = new wxFrame(NULL, -1, _("Hello World"), wxPoint(50, 50),
wxSize(450, 350));
frame->Show(true);
return true;
}
Specifically, why is it that frame
does not leak? When does it get released and whose responsibility is is? In a normal program a pointer that does not get passed to anything and that goes out of scope without being deleted is almost certainly a leak, but apparently this is not so in wxWidgets.