在多级继承中将创建多少vtable compliler [英] how many vtable the compliler will be created in multi-level inheritance
本文介绍了在多级继承中将创建多少vtable compliler的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好
在多级继承中创建compliler多少vtable
Hi everyone
how many vtable the compliler will be created in multi-level inheritance
class Base
{
public:
virtual void function1() {cout<<"Base :: function1()\n";};
virtual void function2() {cout<<"Base :: function2()\n";};
virtual ~Base(){};
};
class D1: public Base
{
public:
~D1(){};
virtual void function1() { cout<<"D1 :: function1()\n";};
};
class D2: public Base
{
public:
~D2(){};
virtual void function2() { cout<< "D2 :: function2\n";};
};
int main()
{
D1 *d = new D1;;
Base *b = d;
b->function1();
b->function2();
delete (b);
return (0);
}
推荐答案
基本上是'每个班级一个v表'。每个类意味着,一个类本身具有虚函数或覆盖其中一个父虚函数。
参见这个答案。 [ ^ ] < br $> b $ b
更有用的信息。 [ ^ ] < br $> b $ b
希望这有帮助!!
basically its 'one v-table per class'. per class means, one for a class which itself has a virtual function or overides one of the parents virtual functions.
See this answer.[^]
more useful info.[^]
hope this helps !!
这篇关于在多级继承中将创建多少vtable compliler的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文