I keep getting loads of linker errors that probably have something to do with virtual-functions/definitions and/or static class members... I've seen several relevant posts but none of the solutions suggested work, can you see wht the problem is here? My projects consists of 3 files: BALLS.H #include <iostream> using namespace std; class Ball{ //Abstract Class!! protected: //no Balls will be constructed int durability; bool hidden; public: Ball(int dur=0) :durability(dur), hidden(false){} virtual void hit(){} virtual void rest()=0; virtual int get_state() {} }; class Basket : public Ball { public: Basket(int L1) :Ball(L1) { cout<<"New basketball!"<<endl; count++; } void rest(){} int get_state(); …

Member Avatar
Member Avatar
+0 forum 3

I'm writing classes for widgets on a ui. While planning what I would do, I realized majority of the of the classes would look very similar. What I decided to do was to use a macro that takes a few parameters to define the similar parts of the class bodies. After cleaning a few code errors, I compiled and got a bunch of linker errors. I cleaned and rebuilt a few times with the same result All of the errors say: error: undefined reference to vtable for 'every class using the macro'. I have an idea the errors are related …

Member Avatar
Member Avatar
+0 forum 4

Keeping getting into errors in my code...this looks to be the wierdest so far... [CODE]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) { …

Member Avatar
Member Avatar
+0 forum 1

Hi, i'm new to C++ and i understand someone else has asked this question on this forum before. I read the replies but still don't know how to resolve my error. gcc version is 4.2.2. The linker error i encountered is build_products/shared/x86/sgos_native/debug/gcc_v4.4.2/ced.o: In function `CEA_Disk_lister::CEA_Disk_lister(CEA_Disk*)': ced.cpp:(.text._ZN15CEA_Disk_listerC1EP8CEA_Disk[_ZN15CEA_Disk_listerC1EP8CEA_Disk]+0x25): undefined reference to `vtable for CEA_Disk_lister' And following is the class declerations [CODE]class CEA_Disk_lister : public CEA_Process { private: enum { DISK_LISTER_PROCESS_STACK_SIZE = 0x800, PRIORITY_RELATIVE_TO_DISK_PROCESS = -1, // Interval between polling for disk initialization complete DELAY_FOR_DISK_INITIALIZATION = 15000, }; private: CEA_Disk *Disk;/*mtc*/ private: void Process(void); public: CEA_Disk_lister( CEA_Disk *my_disk ) : Disk( my_disk ) …

Member Avatar
Member Avatar
+0 forum 1

Arrival.o: In function `NodeItem': /home/jonyb/Desktop/A3-Q2/NodeItem.h:5: undefined reference to `vtable for NodeItem' Arrival.o: In function `~Event': /home/jonyb/Desktop/A3-Q2/Event.h:8: undefined reference to `NodeItem::~NodeItem()' Event.o:(.rodata._ZTI5Event[typeinfo for Event]+0x8): undefined reference to `typeinfo for NodeItem' These 3 errors repeat themselves for all my files accessing NodeItem.h and NodeItem.cpp Now I've looked around and all I could find was that I need to have a body (albeit empty) for my NodeItem virtual destructor, I do have it for NodeItem. I have to admit the whole destructor thing has got me confused since all the example I've seen are either empty of only contain a cout or cerr …

Member Avatar
Member Avatar
+0 forum 2

The End.