空类的大小是多少? [英] what is the size of empty class?

查看:171
本文介绍了空类的大小是多少?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



c ++中空类的大小是多少,如果该类只包含一个VTABLE那么大小是多少?





请解释一下?



问候,

Ranjith

Hi ,
what is the size of empty class in c++ and if the class contain only one VTABLE then what is the size?


Please explain?

Regards,
Ranjith

推荐答案

int main()
{
    class empty {};
    printf ("Size of empty is %d", sizeof(empty));
    return 0;
}



关于VTable,虚拟析构函数和类似版本 - 谷歌是你的朋友。



希望这有帮助,

Pablo。


About VTable, virtual destructors and similar - google is your friend.

Hope this helps,
Pablo.


是非零,你可能会看到原因,例如:\"Empty Classes[ ^ ]。
Is is non-zero, you may see the reason, for instance, here: "Empty Classes" at MSDN[^].


您花时间更好地学习语言而不是随意发布问题这里。您可以先阅读 Bjarne Stroustrup'网站上的所有内容[ ^ ]。
Your time would be much better spent studying the language in detail rather than randomly posting questions here. You could start by reading everything on Bjarne Stroustrup''s website[^].


这篇关于空类的大小是多少?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆