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

Smart Pointers in C++ and How to Use Them

Operator Overloading in C++

How would you read in a string of unknown length without risking buffer overflow