#include <iostream>
typedef class
{
public:
struct
{
int b;
int c;
}a;
struct
{
bool e;
char f;
}d;
}NEWTYPE;
int main()
{
NEWTYPE *S = NULL;
std::cout << sizeof(NEWTYPE) << std::endl;
system("pause");
return 0;
typedef class
{
public:
struct
{
int b;
int c;
}a;
struct
{
bool e;
char f;
}d;
}NEWTYPE;
int main()
{
NEWTYPE *S = NULL;
std::cout << sizeof(NEWTYPE) << std::endl;
system("pause");
return 0;
}
//结果为12.,说明内存对齐并不以结构体作为基准
/*将其改为如下*/
#include <iostream>
typedef class
{
public:
struct
{
struct
{
int b;
int c;
}a;
bool e;
char f;
}d;
}NEWTYPE;
//结果不变