2013-12-12 86 views
0

我有點新手,這一切的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(); 
}; 

我在這個Screen::show();調用中出現此錯誤:D:\MosyncProjects\Views\ListScreen.cpp:22: Error: Unresolved symbol '__ZN4MAUI6Screen4showEv' line 22(爲了本主題的目的,我刪除了一些代碼)。那麼我在這裏做錯了什麼?

+2

你的代碼沒有問題。這是一個鏈接器錯誤,而不是編譯器錯誤。你需要鏈接定義'Screen :: show()'的庫。 –

+0

該死的......那麼我該怎麼辦?重新啓動我的IDE,重新啓動我的電腦?格式化磁盤? :D –

+0

顯然你沒有提供'Screen :: show()'的實現,或者沒有鏈接它駐留的目標文件/庫。 –

回答

4

您正在包含頭文件,該文件告訴函數Screen::show()存在,但可能不會鏈接具有實現的庫。

看到這個頁面:http://www.mosync.com/docs/sdk/cpp/guides/libs/working-with-mosync-libraries/index.html

具體做法是:

As well as referencing the header files in your application code, you also need to specify the actual libraries that you want to use in the project's Build Settings (Project > Properties > MoSync Project > Build Settings):

看起來maui.lib應該包含屏幕代碼。

+0

是的,maui.lib包含此代碼。謝謝! –