错误LNK2019未解析的外部符号

时间:2014-10-12 19:16:58

标签: c++

我已经阅读了有关stackoverflow的几篇相关文章,但无法将解决方案与我的代码中的问题联系起来。错误描述是

1>CAN.obj : error LNK2019: unresolved external symbol "public: __thiscall CLogObjectCAN::CLogObjectCAN(class CString)" (??0CLogObjectCAN@@QAE@VCString@@@Z) referenced in function "void __cdecl `dynamic initializer for 'd_obj''(void)" (??__Ed_obj@@YAXXZ)

为什么编译器抛出这个错误?,我在OOP中不好,试图修改一些现有的模式。

CAN.cpp

#include "BaseLogObject.h"
 #include "LogObjectCAN.h" 
CString s2( "version" );
CLogObjectCAN *d_obj = new CLogObjectCAN(s2);
CBaseLogObject *obj = d_obj;

static int config_print_error(int error, int channel) {
    CString Header= "";
    obj->vLog_Embaserror(Header, "EMBAS");
}

BaseLogObject.h

class CBaseLogObject {
public:
    CBaseLogObject(CString omVersion);

    ~CBaseLogObject();
virtual void vLog_Embaserror(CString& omHeader, char* mHeader);
};

BaseLogObject.cpp

#include "BaseLogObject.h"
CBaseLogObject::CBaseLogObject(CString omVersion):m_omVersion(omVersion) {
    vResetValues();
} 
void CBaseLogObject:: vLog_Embaserror(CString& omHeader, char* mHeader) {
    omHeader = "***EMBAS ";

}

LogObjectCAN.h

#include "BaseLogObject.h"
class LogObjectCAN: public CBaseLogObject {
public:

void vLog_Embaserror(CString& omHeader, char* mHeader);
public:
    CLogObjectCAN(CString omVersion);    
    ~CLogObjectCAN(); 
}

LogObjectCAN.cpp

#include "LogObjectCAN.h" 
    CLogObjectCAN::CLogObjectCAN(CString omVersion):CBaseLogObject(omVersion) {
        // Initialise the filtering block
        m_sFilterApplied.vClear();
        m_pasControllerDetails = NULL;
        m_nNumChannels = 0;
    }
    void CLogObjectCAN::vLog_Embaserror(CString& omHeader, char* mHeader) {
        if(strcmp(mHeader, "EMBAS")== 0) {
            CBaseLogObject::vLog_Embaserror(omHeader, "driver");
            omHeader += CAN_Embas;
            omHeader += L'\n';
        }
    }

0 个答案:

没有答案