开发者

undefined reference to vtable [duplicate]

This question already has answers here: Undefined reference to vtable (21 answers) Closed 3 years ago.

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开发者_如何学C of that error.

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


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.


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;

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜