c++ - Undefined reference to vtable for Compte -


i'm trying build c++ project course i'm following , i'm having lot of troubles.

i have header:

#ifndef compte_h_ #define compte_h_  #include <string>  class compte { public:     compte (unsigned int p_nocompte, double p_tauxinteret, double p_solde,const std::string& p_description);     virtual ~compte (){} ;      void asgsolde (const double p_solde);     unsigned int reqnocompte () const;     double reqtauxinteret () const;     double reqsolde () const;     std::string reqdescription () const;     std::string reqcompteformate() const;      virtual compte* clone() const;      virtual const double calculerinteret(); private:     unsigned int m_nocompte;     double m_tauxinteret;     double m_solde;     std::string m_description; };  #endif /* compte_h_ */ 

and corresponding cpp file:

#include "compte.h" #include <string> #include <sstream> using namespace std;  compte::compte (unsigned int p_nocompte, double p_tauxinteret, double p_solde, const string& p_description) : m_nocompte(p_nocompte), m_tauxinteret(p_tauxinteret), m_solde(p_solde), m_description(p_description) {  }  void compte::asgsolde (const double p_solde) {     m_solde = p_solde; }  unsigned int compte::reqnocompte () const{     return m_nocompte; }  double compte::reqtauxinteret() const{     return m_tauxinteret; } double compte::reqsolde() const{     return m_solde; }  string compte::reqdescription() const{     return m_description; }  string compte::reqcompteformate()const {     ostringstream compteformate;      return compteformate.str(); } 

however have following errors popping:

description resource    path    location    type undefined reference « vtable compte »    compte.cpp  /travail pratique 2 line 14 c/c++ problem 

for constructor in .cpp file,

description resource    path    location    type undefined reference « vtable compte »    compte.cpp  /travail pratique 2 line 14 c/c++ problem 

for class compte{ line in .header file, , lastly

description resource    path    location    type undefined reference « vtable compte »    compte.h    /travail pratique 2 line 16 c/c++ problem 

for virtual ~compte(){}; line.

what's wrong code, how can correct this?

you forgot implement 2 virtual methods, clone , calculerinteret. why linker complaining. linker not complaining destructor has trouble creating virtual method table because 2 methods marked virtual, missing. linker can find issues because in theory these methods can spread on multiple source files.

if intent create abstract methods :

virtual compte* clone() const=0; virtual const double calculerinteret()=0; 

of course realise cannot instantiate classes have abstract methods right ?


Comments

Popular posts from this blog

java - Could not locate OpenAL library -

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

sorting - opencl Bitonic sort with 64 bits keys -