Keeping getting into errors in my code...this looks to be the wierdest so far...

class bug: public living{
      protected:
              bool ate;
              int energy;
      public:
             virtual void moveToFood(point hunter, point food);
             bool eatIt(point hunter, point food){
                  int hx, hy, fx, fy;
                  hx=hunter.getx();
                  hy=hunter.gety();
                  fx=food.getx();
                  fy=food.gety();
                  if((hy==fy)&&(hx==fx))
                       ate=true;
                  else
                       ate=false;
                  return ate;
             }
             void setEnergy(int nrg){energy=nrg;}
             int getEnergy(){return energy;}
             virtual void print()const{location.print();}
};
class ladybug: public bug{
      public:
             ladybug(int u, int v){location.set(u,v);energy=0;}
             void moveToFood(point hunter, point food){
                  int hx, hy, fx, fy;
                  hx=hunter.getx();
                  hy=hunter.gety();
                  fx=food.getx();
                  fy=food.gety();
                  if(hx<fx)
                  {
                       hx+=2;
                       if(hx>fx)
                       hx--;
                  }         
                  else if(hx>fx)
                  {
                       hx-=2;
                       if(hx<fx)
                       hx++;
                  }
                  else if(hy<fy)
                  {
                       hy+=2;
                       if(hy>fy)
                       hy--;
                  }
                  else if(hy>fy)
                  {
                       hy-=2;
                       if(hy<fy)
                       hy++;      
                  }
                  location.set(hx,hy);
             }
            void print()const{
                  cout<<"The ladybug is at ";
                  location.print();
                  if(ate==true)
                  cout<<"It just ate an aphid."<<endl;
                  else
                  cout<<"It is still hungry."<<endl;
             }
};

When ever I try to declare a ladybug or other derived class object I get that
undefined reference to 'vtable for bug' error. What is going on?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.