이 비주얼 스튜디오 2010 컴파일러 (이 micrsoft 비주얼 스튜디오 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