我正在创建一些自定义异常类,执行以下操作
class GXException
{
public:
GXException(LPCWSTR pTxt):pReason(pTxt){};
LPCWSTR pReason;
};
class GXVideoException : GXException
{
public:
GXVideoException(LPCWSTR pTxt):pReason(pTxt){};
LPCWSTR pReason;
};
当我创建 GXVideoException 来扩展 GXException 时,出现以下错误
1>c:\users\numerical25\desktop\intro todirectx\godfiles\gxrendermanager\gxrendermanager\gxrendermanager\gxexceptions.h(14) : error C2512: 'GXException' : no appropriate default constructor available
您需要在派生构造函数的初始值设定项列表中调用基类构造函数。此外,由于您是从基类派生的,因此您不应重新声明同名的第二个变量(pReason
).
class GXException
{
public:
GXException(LPCWSTR pTxt):pReason(pTxt){};
LPCWSTR pReason;
};
class GXVideoException : GXException
{
public:
GXVideoException(LPCWSTR pTxt)
: GXException(pTxt)
{}
};
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)