现在的位置: 首页 > 综合 > 正文

Programming Basic–what is the output of the following code?

2012年09月29日 ⁄ 综合 ⁄ 共 368字 ⁄ 字号 评论关闭
#include "iostream"
#include"string.h"
#include "stdio.h"

class A{
};

class A2{
char d,e;
};

struct B{
};

struct C{
char b,c;
};

struct D{
int x,y;
};

int main()
{
count<<sizeof(A)<<endl;
cout<<sizeof(A2)<<endl;
A *p1=new A();
A *p2;
A *p3;
cout<<sizeof(p1<<endl;
cout<<sizeof(p2)<<endl;
cout<<sizeof(p3)<<endl;
cout<<sizeof(B)<<endl;
cout<<sizeof(C)<<endl;
cout<<sizeof(D)<<endl;

return 0;
}

Answer:
1,2,4,1,4,1,2,8

抱歉!评论已关闭.