标签:运行 指针 mamicode include 32位 space class mic ima
源程序:
//基类与子类占用空间及字节对齐
#include<iostream>
using namespace std;
class BaseClass
{
int v1,v2;
char v4;
public:
int temp1(){}
};
class DerivedClass:public BaseClass
{
int v3;
int *p;
public:
int temp(){}
};
int main()
{
cout<<"Base="<<sizeof(BaseClass)<<endl;
cout<<"Derived="<<sizeof(DerivedClass)<<endl;
return 0;
}
//在32位系统中,指针的大小是4字节,而不是8字节
运行结果:
标签:运行 指针 mamicode include 32位 space class mic ima
原文地址:https://www.cnblogs.com/duanqibo/p/12259407.html