3

我正在尝试将一些有效的 Visual C++ 代码导入 Qt Creator,但我遇到了一些我无法解释的编译错误。这是我的代码:

// TabSprite.h

#include <GraphicsItem.h>

namespace appetizer {

class TabSprite : public GraphicsItem {

public:

  TabSprite(GraphicsWindow* parentWindow);

}

// TabSprite.cpp

#include <TabSprite.h>
using namespace appetizer;

TabSprite::TabSprite(GraphicsWindow* parentWindow): GraphicsItem(parentWindow) {

}

Qt Creator 给了我这个错误(在构造函数声明中TabSprite.cpp):

对 'appetizer::GraphicsItem::GraphicsItem(appetizer::GraphicsWindow*) 的未定义引用

但是GraphicsItem已正确声明,GraphicsItem.h因此我不明白为什么编译器找不到它。任何人都可以看到这段代码有什么问题吗?

4

2 回答 2

3

这意味着您没有定义GraphicsItem.

于 2011-01-03T14:03:58.953 回答
0

The constructor is probably declared in TabSprite.h (although your code doesn't show that). That's why it compiles. But the constructor isn't defined anywhere, or, less likely, the unit where it is defined isn't included in the linking process. That's why it doesn't link.

于 2011-01-03T14:08:41.557 回答