Have a look at this - C++ corner case: You can implement pure virtual functions in the base class
LNK2019 error with implemented virtual functions
I'm getting a LNK2019 error with implemented virtual functions.
In the base class the functions are declared as virtual with =0 to make them pure virtual.
In the base class constructor I call these pure virtual functions, assuming that the base class will call the appropriate derived class function.
As I write that I realize that maybe the base class has no idea which derived function to call and tries to link with its own pure virtual function. which of course it cannot find.
CClassifier::CClassifier(CComPtr<ComponentDefinition>& pAsmCompDef,
CComPtr<Document>& pGenAsmDoc,
const CString& kcsClassName)
: m_kcsSapCode(GetCodiceSAPFromInventorDoc(pGenAsmDoc))
, m_kcsClassName (kcsClassName)
{
// Here the base class is trying to call pure virtual functions
// Doing this gives me a NLK2019 error
InitTagIdDescList () ;
InitAttValPairList (pAsmCompDef,pGenAsmDoc) ;
}
If I do the call in the derived class, I do not get the link error:
CClassifierCct3D::CClassifierCct3D(CComPtr<ComponentDefinition>& pCompDef,
CComPtr<Document>& pGenAsmDoc,
const CString& kcsClassName)
: CClassifier (pCompDef,pGenAsmDoc,kcsClassName)
{
// links ok...
InitTagIdDescList () ;
InitAttValPairList (pCompDef,pGenAsmDoc) ;
}
Is my reasoning about why I got the error correct?
If so why doesn't the compiler tell me I cannot call pure virtual functions?
Where am I? Who am I?