簡體   English   中英

從模板派生類中調用模板基類的構造方法

[英]Calling constructor of a template base class from a template derived class

我正在將一些代碼從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)'|

關於為何收到此錯誤以及如何解決該錯誤的任何建議?

看來, EffectFramework的候選構造EffectFrameworkstd::wstring&作為第一個和第二個參數,但是您正在傳遞臨時變量。 例如,如果您要傳遞全局變量,則它應該起作用。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM