2015-03-24 176 views
0

我將一些代碼從Visual Studio移植到了Mingw GCC。這段代碼在Visual Studio上運行良好,但是當我嘗試在Mingw中構建它時,我得到以下問題。下面從模板派生類調用模板基類的構造函數

HeaderFile 
template <MThread Thread> 
class AFWork : public EffectFramework<Thread> 
{ 
public: 
    AFWork(HINSTANCE hinst, HWND hWindow, 
         const std::wstring& stSharedDataPath, 
         const std::wstring& stGameDataPath, 
         const std::wstring& stExtendedGameDataPath, 
         int nScrWidth, int nScrHeight); 
    virtual ~AFWork(void); 
    ... 
    ... 
}; 

即上面提到的基類的其他頭文件中的代碼中給出的是:

HeaderFile 
template <MThread Thread> 
class EffectFramework : public ktWin32Framework 
{ 
public: 
    typedef boost::function<void (int window_no, HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)> WindowProcedure; 

    EffectFramework<Thread>(std::wstring& name, 
          std::wstring& dataDirPrefix, 
          VSYNC vsync, 
          HINSTANCE hinst, 
          HINSTANCE hprevinst, 
          LPSTR args, 
          int mode, 
          IApplicationManager* appl_manager = NULL); 
    .... 
    .... 
}; 

執行力度派生類

    template <MThread Thread> 
        AFWork<Thread>::AFWork(HINSTANCE hinst, 
              HWND hWindow, 
              const std::wstring& stSharedDataPath, 
              const std::wstring& stGameDataPath, 
              const std::wstring& stExtendedDataPath, 
              int nScrWidth, 
              int nScrHeight) 

: EffectFramework<Thread>::EffectFramework(wstring(L"ArtViewer"), wstring(L""), VSYNC::VSYNC_1, hinst, NULL, NULL, 0, NULL) <---ERROR 
{ 
} 

錯誤的構造的該我得到的是這個

error: no matching function for call to 'T_Wrapper::EffectFramework<(T_Wrapper::T_Thread)0u>::EffectFramework(std::wstring, std::wstring, T_Wrapper::VSYNC, HINSTANCE__*&, int, int, int, int)'| 

爲什麼我得到這個錯誤以及如何解決它的任何建議?

回答

1

似乎,來自EffectFramework的候選構造函數具有std::wstring&作爲第一個和第二個參數,但是您正在傳遞臨時變量。例如,如果你要傳遞全局變量,那麼它應該工作。

+0

真棒捕捉 – MistyD 2015-03-24 22:31:28

+0

很高興這有幫助 – tonso 2015-03-24 22:31:58

相關問題