i am learning about C++ and object oriented programming. Have a small doubt -
class CA
{
void fun()
{
int x;
}
};
class CB
{
int y;
};
int main()
{
CA obj;
CB obj1;
cout<<sizeof(obj)<<'\t'<<sizeof(obj1);
}
When i run the above code, i get size of obj as '1' byte while size of obj1 as '4' byte. Why is that? Both the classes have integers, so size should be the same? How is the size of a class is calculated?