Cor*_*y D 7 c++ linker qt abstract-class
所以,我有一个抽象类Panel和它的实现MyPanel.他们看起来像这样:
class Panel : public QWidget
{
public:
Panel(QWidget* parent = 0) = 0;
virtual ~Panel() = 0;
// but wait, there's more!!
};
class MyPanel : public Panel
{
public:
MyPanel(QWidget* parent = 0);
~MyPanel() {}; // nothing to do here
};
MyPanel::MyPanel(QWidget* parent) :
Panel(parent)
{
// you must construct additional pylons
}
Run Code Online (Sandbox Code Playgroud)
我从VC++中获取构造函数/析构函数的链接器错误
error LNK2019: unresolved external symbol "public: virtual __thiscall Panel::~Panel(void)" (??1Panel@@UAE@XZ) referenced in function "public: virtual __thiscall MyPanel::~MyPanel(void)" (??1MyPanel@@UAE@XZ) mypanel.obj
error LNK2019: unresolved external symbol "public: __thiscall Panel::Panel(class QWidget *)" (??0Panel@@QAE@PAVQWidget@@@Z) referenced in function "public: __thiscall MyPanel::MyPanel(class QWidget *)" (??0MyPanel@@QAE@PAVQWidget@@@Z) mypanel.obj
Run Code Online (Sandbox Code Playgroud)
为什么我收到此链接器错误?
- - 答案 - -
class Panel : public QWidget
{
public:
Panel(QWidget* parent = 0) : QWidget(parent) {};
virtual ~Panel() {};
// but wait, there's more!!
};
Run Code Online (Sandbox Code Playgroud)
我以为我在午餐前尝试过这个.事实证明我错了.
| 归档时间: |
|
| 查看次数: |
6190 次 |
| 最近记录: |