c++ - Undefined reference to vtable in final class constructor and destructor -


this question has answer here:

hello trying learn c++ book "c++ introduction programming jesse liberty , jim keogh" doing questions chapter 12 multiple inheritance. q4 asks me derive car , bus vehicle car adt , derive sportscar, wagon , coupe car , implement non pure virtual function vehicle in car. compiling on codelite @ build time gives error

undefined reference 'vtable coupe' on constructor , destructor coupe

please can tell me doing wrong can learn more how handle virtual function definitions correctly vtables.

#include <iostream>  using namespace std;  class vehicle { public: vehicle(){}; virtual ~vehicle(){}; virtual int getitsspeed() = 0; int getitstyresize(); virtual int getitsregistration() { return itsregistration; } protected: int itsspeed; int itsregistration; };  class car : public vehicle { public: car(){}; virtual ~car(){}; virtual int getitsspeed() = 0; int getitsbootsize() { return itsbootsize; } int getitsregistration() { return itsregistration; } virtual int getitsradiovolume() = 0; int getitstyresize() { return itstyresize; } protected: int itsbootsize; int itsradiovolume; int itstyresize; };  class bus : public vehicle { bus(){}; ~bus(){}; public: int getitsspeed() { return itsspeed; } int getitspassengersize() { return itspassengersize; } private: int itspassengersize; };  class sportscar : public car { public: sportscar(){}; ~sportscar(){}; int getitsspeed() { return itsspeed; } int getitspowersteeringaccuracy() { return itspowersteeringaccuracy; } private: int itspowersteeringaccuracy; };  class wagon : public car { public: wagon(){}; ~wagon(){}; int getitsspeed() { return itsspeed; } int getitstrailersize() { return itstrailersize; } private: int itstrailersize; };  class coupe : public car { public: coupe(){ itstyresize = 10; } ~coupe(){}; int getitsspeed(); int getitsinteriorstyle() { return itsinteriorstyle; } int getitsradiovolume() { return itsradiovolume; } private: int itsinteriorstyle; };  void startof() { coupe mariescoupe; cout << "maries coupe has tyre size of " << mariescoupe.getitstyresize() << " .\n\n";  }  int main() { startof(); return 0; } 

you should implement getitsspeed in coupe. example,

int coupe::getitsspeed() {return 0;}; 

Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -