码迷,mamicode.com
首页 > 其他好文 > 详细

类的大小

时间:2018-06-25 22:49:01      阅读:180      评论:0      收藏:0      [点我收藏+]

标签:short   static   指针   有关   函数指针   size   str   virtual   虚函数   

类的大小只与成员变量(非static数据成员变量)和虚函数指针有关,还要考虑到对齐

例:class A

{

   A(){}

  virtual ~A(){}

 int m1;

short m2;

};

A的size=4+4(考虑对齐)+4(虚函数指针) = 12

类的大小

标签:short   static   指针   有关   函数指针   size   str   virtual   虚函数   

原文地址:https://www.cnblogs.com/mcyushao/p/9226529.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!