Question

I seem to be having an issue with a wxWidgets project I'm working on. I keep getting a vtable linker error for a class that doesnt involve any virtual functions. I was wondering if someone could shed some light on this issue, since in my understanding there shouldnt be a vtable for a class that doesnt use virtual functions. Most similar topics I've seen occur when someone forgets the define the deconstructor, but I'm pretty sure the deconstructor was correctly defined. the errors can be seen below.

||=== Hike Planner GUI, Debug ===|
obj\Debug\GUIFrame.o||In function `PlanWindow':|
E:\Projects\Hike Planner GUI\GUIFrame.cpp|76|undefined reference to `vtable for              PlanWindow'|
E:\Projects\Hike Planner GUI\GUIFrame.cpp|76|undefined reference to `vtable for PlanWindow'|
obj\Debug\GUIFrame.o||In function `~PlanWindow':|
E:\Projects\Hike Planner GUI\GUIFrame.cpp|81|undefined reference to `vtable for PlanWindow'|
E:\Projects\Hike Planner GUI\GUIFrame.cpp|81|undefined reference to `vtable for PlanWindow'|
E:\Projects\Hike Planner GUI\GUIFrame.cpp|81|undefined reference to `vtable for PlanWindow'|
||=== Build finished: 5 errors, 0 warnings ===|

segment from GUIFrame.h

class PlanWindow : public wxWindow
{
    DECLARE_EVENT_TABLE()

    public:
        PlanWindow(wxWindow* parent, wxWindowID id);

        ~PlanWindow();

        void GetLocationList(int RetCode);

        wxListBox *PlanList;
};

Segment from GUIFrame.cpp:

PlanWindow::PlanWindow(wxWindow* parent, wxWindowID id) : wxWindow(parent,id) 
{

}

PlanWindow::~PlanWindow()
{

}

void PlanWindow::GetLocationList(int RetCode)
{
    if(RetCode == DEST)
    {

    }
    else if(RetCode == TH)
    {

    }
    else if(RetCode == FREE)
    {

    }
    else
    {

    }
}

any help at all would be great. the errors occur at the contructor and destructor definitions.

Was it helpful?

Solution

You also need to implement the declared event table using BEGIN_EVENT_TABLE/END_EVENT_TABLE in your cpp file. An example;

BEGIN_EVENT_TABLE(PlanWindow, wxWindow)
//  EVT_SIZE (PlanWindow::OnSize)       // Example size handler
END_EVENT_TABLE()
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top