structure or class padding

// SizeofClass.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>


class CE
{
};
class CA
{

int i1;
char c1;

};
class CB
{
int i1;
char c1;
int i2;
double d1;

};

int _tmain(int argc, _TCHAR* argv[])
{
std::cout<<sizeof(int)<<std::endl;
std::cout<<sizeof(double)<<std::endl;
std::cout<<sizeof(char)<<std::endl;
std::cout<<sizeof(CE)<<std::endl;
std::cout<<sizeof(CA)<<std::endl;
std::cout<<sizeof(CB)<<std::endl;
return 0;
}

Comments

Popular posts from this blog

How to programmatically compile code using C# compiler

Difference Between Vector vs List

Virtual Functions