เมื่อสร้างโปรแกรม C ++ ฉันจะได้รับข้อความแสดงข้อผิดพลาด
การอ้างอิงที่ไม่ได้กำหนดถึง 'vtable ...
สาเหตุของปัญหานี้คืออะไร? ฉันจะแก้ไขได้อย่างไร
มันเกิดขึ้นที่ฉันได้รับข้อผิดพลาดสำหรับโค้ดต่อไปนี้ (คลาสที่เป็นปัญหาคือ CGameModule) และฉันไม่สามารถใช้ชีวิตของฉันได้เข้าใจว่าปัญหาคืออะไร ตอนแรกฉันคิดว่ามันเกี่ยวข้องกับการลืมที่จะให้ร่างกายเสมือนการทำงาน แต่เท่าที่ฉันเข้าใจทุกอย่างอยู่ที่นี่ ห่วงโซ่การสืบทอดมีความยาวเล็กน้อย แต่นี่คือซอร์สโค้ดที่เกี่ยวข้อง ฉันไม่แน่ใจว่าข้อมูลอื่น ๆ ที่ฉันควรให้คืออะไร
หมายเหตุ: คอนสตรัคเตอร์เป็นที่ที่ข้อผิดพลาดนี้เกิดขึ้นดูเหมือนว่าจะเกิดขึ้น
รหัสของฉัน:
class CGameModule : public CDasherModule {
 public:
  CGameModule(Dasher::CEventHandler *pEventHandler, CSettingsStore *pSettingsStore, CDasherInterfaceBase *pInterface, ModuleID_t iID, const char *szName)
  : CDasherModule(pEventHandler, pSettingsStore, iID, 0, szName)
  { 
      g_pLogger->Log("Inside game module constructor");   
      m_pInterface = pInterface; 
  }
  virtual ~CGameModule() {};
  std::string GetTypedTarget();
  std::string GetUntypedTarget();
  bool DecorateView(CDasherView *pView) {
      //g_pLogger->Log("Decorating the view");
      return false;
  }
  void SetDasherModel(CDasherModel *pModel) { m_pModel = pModel; }
  virtual void HandleEvent(Dasher::CEvent *pEvent); 
 private:
  CDasherNode *pLastTypedNode;
  CDasherNode *pNextTargetNode;
  std::string m_sTargetString;
  size_t m_stCurrentStringPos;
  CDasherModel *m_pModel;
  CDasherInterfaceBase *m_pInterface;
};
มรดกจาก ...
class CDasherModule;
typedef std::vector<CDasherModule*>::size_type ModuleID_t;
/// \ingroup Core
/// @{
class CDasherModule : public Dasher::CDasherComponent {
 public:
  CDasherModule(Dasher::CEventHandler * pEventHandler, CSettingsStore * pSettingsStore, ModuleID_t iID, int iType, const char *szName);
  virtual ModuleID_t GetID();
  virtual void SetID(ModuleID_t);
  virtual int GetType();
  virtual const char *GetName();
  virtual bool GetSettings(SModuleSettings **pSettings, int *iCount) {
    return false;
  };
 private:
  ModuleID_t m_iID;
  int m_iType;
  const char *m_szName;
};
ซึ่งสืบทอดมาจาก ....
namespace Dasher {
  class CEvent;
  class CEventHandler;
  class CDasherComponent;
};
/// \ingroup Core
/// @{
class Dasher::CDasherComponent {
 public:
  CDasherComponent(Dasher::CEventHandler* pEventHandler, CSettingsStore* pSettingsStore);
  virtual ~CDasherComponent();
  void InsertEvent(Dasher::CEvent * pEvent);
  virtual void HandleEvent(Dasher::CEvent * pEvent) {};
  bool GetBoolParameter(int iParameter) const;
  void SetBoolParameter(int iParameter, bool bValue) const;
  long GetLongParameter(int iParameter) const;
  void SetLongParameter(int iParameter, long lValue) const;
  std::string GetStringParameter(int iParameter) const;
  void        SetStringParameter(int iParameter, const std::string & sValue) const;
  ParameterType   GetParameterType(int iParameter) const;
  std::string     GetParameterName(int iParameter) const;
 protected:
  Dasher::CEventHandler *m_pEventHandler;
  CSettingsStore *m_pSettingsStore;
};
/// @}
#endif
          qmake -projectจากนั้นqmake) เพื่อสร้างใหม่Makefileนั่นเป็นแหล่งที่มาของข้อผิดพลาดเมื่อใช้ Qt
                Q_OBJECTคัดลอกภายนอก แต่ยังไม่ได้เป็นส่วนหนึ่งของไฟล์. pro ถึงแม้ว่ามันจะรวบรวมได้ดี เราต้องเพิ่มว่า.h/.cppไฟล์ลงในแฟ้ม .pro qmakeเพื่อให้สามารถ