您的位置:首页 > 编程语言 > C语言/C++

【ThinkingInC++】25、用sizeof运算符可以确定struct的长度。

2014-08-18 08:09 471 查看
/**
* 功能:用sizeof运算符可以确定struct的长度。
* 时间:2014年8月18日08:10:14
* 作者:cutter_point
*/

#include"CLib.h"
#include"CppLib.h"
#include<iostream>

using namespace std;

struct A
{
    int i[100];
};

struct B
{
    void f();
};

void B::f(){}

int main()
{
    cout<<" sizeof struct A= "<<sizeof(A)<<" bytes"<<endl;
    cout<<" sizeof struct B= "<<sizeof(B)<<" bytes"<<endl;
    cout<<" sizeof CStash in C= "<<sizeof(CStash)<<" bytes"<<endl;
    cout<<" sizeof CStash in C++= "<<sizeof(Stash)<<" bytes"<<endl;

    return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: