【发布时间】:2013-12-12 18:26:26
【问题描述】:
我对所有这些 c++ 东西有点新手,所以这可能是初学者的问题:
ListScreen.h
#ifndef _LISTSCREEN_H_
#define _LISTSCREEN_H_
#include "MAUI/Screen.h"
namespace CoolPlaces {
namespace Views {
using namespace MAUI;
class ListScreen : public Screen {
public:
ListScreen();
~ListScreen();
void keyPressEvent(int keyCode, int nativeCode) {}
void keyReleaseEvent(int keyCode, int nativeCode) {}
void pointerPressEvent(MAPoint2d point) {}
void pointerReleaseEvent(MAPoint2d point) {}
void pointerMoveEvent(MAPoint2d point) {}
void show();
};
}
}
#endif //_LISTSCREEN_H_
ListScreen.cpp
#include "MAUI/Screen.h"
#include "ListScreen.h"
using namespace MAUI;
using namespace CoolPlaces::Views;
void ListScreen::show() {
Screen::show();
};
我收到此错误:D:\MosyncProjects\Views\ListScreen.cpp:22: Error: Unresolved symbol '__ZN4MAUI6Screen4showEv' line 22 在此 Screen::show(); 调用中(出于本主题的目的,我删除了一些代码)。那么我到底做错了什么?
【问题讨论】:
-
您的代码没有问题。那是链接器错误,而不是编译器错误。您需要链接定义
Screen::show()的库。 -
该死的......那我该怎么办?重启我的IDE,重启我的电脑?格式化磁盘? :D
-
显然您没有为
Screen::show()提供实现,或者没有链接它所在的目标文件/库。 -
'重启我的IDE,重启我的电脑?格式化磁盘?' 这些都不会更正您的链接器输入...
-
@Taylor 我将库与 show 方法的定义链接(头文件,对吗?),但它仍然不起作用。