对 vtable 的未定义引用
我有一个类afpooills
,它可以帮助在我们的内存管理模块中查找数据。 (不要问为什么我不知道为什么有这样一个奇怪的名字)
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));
}
我不断收到
[链接器错误]对`afporoills的vtable`的未定义引用,
但我不知道什么是vtable!我没有使用过,为什么会出现错误?
请帮助我,因为如果我不消除该错误,我将无法继续编写该课程。
另外,我还需要做什么才能使 test
方法图灵完整?
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 ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可能会收到此错误,因为您在基类中声明了虚拟方法但没有定义它,即基类中没有提供虚拟函数的函数体。
尝试给它一些虚拟主体并编译它可能会起作用。我最近在类似的情况下遇到了这个错误,通过提供定义修复了该错误。
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.
该错误表明您没有定义基类的虚拟函数,并且编译器无法在基类的虚拟方法表中找到该函数。
每个派生类的对象都会有一个虚拟方法表,其中包含派生类中定义的方法的地址。
要解决您的错误,您还可以将此函数定义为 PURE 虚函数,意味着基类中没有函数体,例如:
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: