本文介绍了C ++中的VTable何时创建?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我想知道何时创建vtable?
是在main()之前的启动代码中还是在其他时间?

I would like to know when is a vtable created?Whether its in the startup code before main() or is it at some other point of time??

推荐答案

vtable 不是C ++概念,因此是否使用它们以及何时使用它们将取决于实现。

A vtable isn't a C++ concept so if they are used and when they are created if they are used will depend on the implementation.

通常, vtables 是在编译时创建的结构(因为它们可以在编译时确定)。在运行时创建特定类型的对象时,它们将具有一个 vptr ,它将在构造时初始化为指向静态 vtable

Typically, vtables are structures created at compile time (because they can be determined at compile time). When objects of a particular type are created at runtime they will have a vptr which will be initialized to point at a static vtable at construction time.

这篇关于C ++中的VTable何时创建?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-07 12:37