首页 > 其他 > 详细

对空类型求sizeof

时间:2015-10-17 23:31:36      阅读:303      评论:0      收藏:0      [点我收藏+]
#include <iostream>
using namespace std;

class Empty1
{

};

class Empty2
{
public:
    Empty2(){};
    ~Empty2(){};
};

class Empty3
{
public:
    Empty3(){};
    virtual ~Empty3(){};
};

int main()
{
    cout<<sizeof(Empty1)<<endl; //1
    cout<<sizeof(Empty2)<<endl; //1
    cout<<sizeof(Empty3)<<endl; //4
    return 0;
}

参考:《剑指offer》 p22

对空类型求sizeof

原文:http://www.cnblogs.com/conard/p/4888357.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!