我有基类:
class CDigit
{
private:
int m_iDigit;
public:
CDigit()
{
m_iDigit = 0;
}
CDigit( const int digit )
{
m_iDigit = digit;
}
void setDigit( const int digit )
{
m_iDigit = digit;
}
int getDigit() const
{
return m_iDigit;
}
virtual void output(ostream &x) = 0;
virtual bool less( CDigit *pDigit ) = 0;
};
和派生类
class CExpected : public CDigit
{
private:
int m_iExpFreq;
public:
CExpected() : CDigit()
{
m_iExpFreq = 0;
}
CExpected( const int dig, const int freq) : CDigit(dig)
{
m_iExpFreq = freq;
}
CExpected( const CExpected& ce)
{
m_iExpFreq = ce.m_iExpFreq;
this->setDigit( ce.getDigit() );
}
void output(ostream &x)
{
x<<this->getDigit()<<" "<<this->m_iObsFreq;
}
bool less( CObserved *pDigit )
{
if( ( pDigit->getDigit() == this->getDigit() ) && (pDigit->getObserved() == this->getObserved() ) )
return true;
else
return false;
}
...
};
问题是编译器告诉我 CExpected 是一个抽象类,我无法实例化它。我究竟做错了什么?
编辑:我已经实现了它们,但没有在此处添加它们