6

i have a class afporoills that helps find data in our memory managment module. (dont ask why such a wierd name i have no idea)

class afporoills{
    void** test(int pos);
};
void** afporoills::test(int pos){
    int x=(pos<<3)|1023*x;
    void** ret=(void**)x;
    if((int)ret%16) return this.test(pos+1);
    void* (*fp)(float, uint16__t)=x;
    ret=ret+(*fp)(1.0f, (uint16__t)pos);
    return ret;
}
int test(){
    afporoills afporoills14;
    return ((char*) (uint32_t) ((uint32_t) (void*) afporoills14.test(((((uint32_t)))((char*) (void*))1));

}

i keep getting

[Linker error] undefined reference to `vtable for afporoills`

but i have no idea what a vtable is!!! i havent used one so why are there errors for it?

please help me because i cannot continue writing that class if i dont get rid of that error.

also what do i have to do to make the test method turing-complete ?

n00b
  • 5,642
  • 2
  • 30
  • 48
  • 2
    http://en.wikipedia.org/wiki/Virtual_method_table – DumbCoder Apr 01 '11 at 10:20
  • @DumbCoder thank you for the link but as you can see i dont use virtual methods ! so why is there this error? @aix yes it is required that the method is turing-complete... – n00b Apr 01 '11 at 10:21
  • 6
    Right candidate for the obfuscation contest. Too bad it will not compile :P – BЈовић Apr 01 '11 at 10:23
  • Is this a mistake? `int x=(pos<<3)|1023*x;` What value could `x` have on the right-hand-side of this assignment? – sarnold Apr 01 '11 at 10:27
  • 2
    A sufficiently dumb April Fools is indistinguishable from the real thing. – namey Apr 01 '11 at 12:27

2 Answers2

18

It is likely you got this error because you declared a virtual method in the Base class and did not define it, i.e no function body for the virtual function supplied in base class.

Try giving it some dummy body and compiling it might just work. I got this error just recently in a similar scenario that got fixed by providing a definition.

Keith Pinson
  • 7,835
  • 7
  • 61
  • 104
SSinha
  • 196
  • 1
  • 2
4

The error indicates you didn't define your base class's virtual function and compiler can not find this function in the base class'es Virtual Method Table. Each derived class's object will have this Virtual method table that containing address to method defined in derived class.

To resolve your error, you may also define this function as PURE virtual function, means no function body in base class, for example:

virtual int handle(struct per_thread_traffic_log * pttl)=0;

Houcheng
  • 2,674
  • 25
  • 32