Continuation from last week. What is the sizeof of a class? Wrote a simple program as follows:
//Program tested on Microsoft Visual Studio 2008 - Zahid Ghadialy
#include<iostream>
using namespace std;
class A
{
int a;
};
class B
{
int b;
int someFunc(void) {return b;}
};
class C
{
void someFunc1(void) {};
void someFunc2(void) {};
};
class D : public A
{
void someFunc(void) {};
};
int main()
{
cout<<"Size of class A = "<<sizeof(A)<<endl;
cout<<"Size of class B = "<<sizeof(B)<<endl;
cout<<"Size of class C = "<<sizeof(C)<<endl;
cout<<"Size of class D = "<<sizeof(D)<<endl;
}
The output is as follows:
After finishing this, I found this interesting article here.