これは、Visual Studio 2010のコンパイラ(それはmicrsoftのVisual Studio 2003のコンパイラで問題はないが)エラーC2259:インスタンス化することはできません抽象クラス
error C2259: 'user_param::UserParamB2<std::string>' : cannot instantiate abstract class due to following members:
'bool user_param::UserParamBase::readonly(bool)' : is abstract
c:\qc\qc_daq\src\hfgui3\userparambase.h(128) : see declaration of 'user_param::UserParamBase::readonly'
'bool user_param::UserParamBase::readonly(void)' : is abstract
c:\qc\qc_daq\src\hfgui3\userparambase.h(127) : see declaration of 'user_param::UserParamBase::readonly'
'SIZE user_param::UserParamBase::winSize(void)' : is abstract
c:\qc\qc_daq\src\hfgui3\userparambase.h(129) : see declaration of 'user_param::UserParamBase::winSize'
私のソースコードは次のようにのように見えるとのエラーメッセージです:
class UserParamBase : public UserParamName
{
public:
virtual bool readonly() =0;
virtual bool readonly(bool bReadonly)=0;
virtual SIZE winSize()=0;
virtual bool get()=0;
virtual void create(CWnd* pParentWnd,const RECT& rect)=0;
virtual void close()=0;
virtual void update()=0;
}
...
template <>
class UserParam<string> : public UserParamB2<string>
{
public:
bool get()
{
AutoCritSec acsWnd(m_csWnd, true);
if(m_wnd.combobox && m_wnd.combobox->GetSafeHwnd()) {
CString text;
m_wnd.combobox->GetWindowText(text);
this->assign((LPCSTR) text);
} else if(m_wnd.wnd && m_wnd.wnd->GetSafeHwnd()) {
char* psz=NULL;
string s;
unsigned uSize = m_wnd.wnd->GetWindowTextLength()+1;
try {
psz=new char[uSize];
m_wnd.wnd->GetWindowText(psz,uSize);
s.assign(psz);
}
catch(...) {
if(psz) delete [] psz;
throw;
}
if(psz) delete [] psz;
s.erase(std::remove(s.begin(),s.end(),'\r'),s.end());
this->assign(s);
}
return true;
}
エラーメッセージがthis->assign(s);
声明で発生します。
抽象クラスをインスタンス化することはできません。コンパイラのエラーメッセージは間違っていません。あなたはそれを "修正"することはできません。 –
クラスにインターフェイスを追加してこのエラーを引き起こすことができますので、非常に助けてください... – Deanna