从模板派生类调用模板基类的构造函数
Calling constructor of a template base class from a template derived class
我正在将一些代码从Visual Studio移植到Mingw GCC。这段代码在visualstudio上运行良好,但当我尝试在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
的候选构造函数将std::wstring&
作为第一个和第二个参数,但您正在传递临时变量。例如,如果您要传递全局变量,那么它应该可以工作。
相关文章:
- 在 c++ 中的模板实例化中使用带有构造函数的类作为类型参数
- 参数包构造函数在类模板中隐藏用户定义的转换
- 具有已删除移动和复制构造函数的类的就地构造
- 创建一个没有复制构造函数的类的 std::vector 的 std::vector
- C++构造函数和类?
- 在 C++ 中,默认情况下构造函数为类的数据成员提供的值是多少?
- 如何在其他类中使用参数化构造函数制作类的对象?
- 具有值包装器的可变参数模板构造函数的类构造函数优先级
- 如何使用私有构造函数对类进行单元测试?
- C++虚拟函数:基类函数是调用的,而不是派生的
- c++17在编译时将带有已删除复制构造函数的类添加到std::vector
- 从作为模板参数传递给构造函数的类继承,或者从它们继承
- 继承的构造函数忽略类内初始化
- 模板和隐式构造函数的类定义之外的友元声明
- 具有字符串文本构造函数的类不适用于 const 引用初始化
- 为什么具有私有构造函数的类不阻止从此类继承?如何控制哪些类可以从某个基继承?
- 具有多个非默认构造函数基的Singleton派生类
- 调用基默认构造函数模板类
- 当基类未指定构造函数时,如何使用仅具有带参数的构造函数的类派生基类?
- 构造所有基类不需要默认生成的构造函数