Can you explain does compiler generates vtable for a class which has virtual function and there is no use of that class(object not created in any sort). Say for ex,
class A {
public:
virtual void func() { }
};
int main()
{
return 0;
}
For the above program does compiler creates vtable for the class A? It may be a duplicate question, but i wanted to know the solution. If it is duplicate please provide the link to the source.
The concept of a vtable is an implementation detail, and not part of the C++ standard. When a vtable is needed by your compiler, one is created.
In your case, the class is never used, and compilers won't generate any code at all.
But even if you instantiate the class and call functions with side-effects, if you never use features that necessitate a vtable, one does not need to be generated.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments