我在处理一个wxWidgets项目时遇到了问题。我一直收到一个与任何虚函数无关的类的vtable链接器错误。我想知道是否有人能够解决这个问题,因为据我理解,不使用虚函数的类不应该有vtable。我看到的大多数类似主题都是因为某人忘记定义析构函数,但我相当确定析构函数已经正确定义了。下面可以看到错误信息。
||=== 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 ===|
来自GUIFrame.h的片段
class PlanWindow : public wxWindow
{
DECLARE_EVENT_TABLE()
public:
PlanWindow(wxWindow* parent, wxWindowID id);
~PlanWindow();
void GetLocationList(int RetCode);
wxListBox *PlanList;
};
从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
{
}
}
任何帮助都将是非常棒的。错误发生在构造函数和析构函数定义处。
wxWindow
派生类中,您''总是''有虚函数,例如它的dtor是虚拟的,因为在wxWindow
中它是虚拟的。 - VZ.