C
cppfans
Why the size of an empty struct or class is 1?
i guess 4 before i run this programm.
for example:
compile with Dev C++
#include <stdio.h>
#include <stdlib.h>
typedef struct tagEMPTY
{} EMPTY,*PEMPTY;
class CEmpty
{};
int main()
{
EMPTY e;
CEmpty ce;
printf("%d,%d\n",sizeof(e),sizeof(ce));
printf("%d,%d\n",sizeof(EMPTY),sizeof(CEmpty));
system("PAUSE");
}
i guess 4 before i run this programm.
for example:
compile with Dev C++
#include <stdio.h>
#include <stdlib.h>
typedef struct tagEMPTY
{} EMPTY,*PEMPTY;
class CEmpty
{};
int main()
{
EMPTY e;
CEmpty ce;
printf("%d,%d\n",sizeof(e),sizeof(ce));
printf("%d,%d\n",sizeof(EMPTY),sizeof(CEmpty));
system("PAUSE");
}