//----------------------------------------------------
//AUTHOR: lanyang123456
//DATE: 2014-11-13
//---------------------------------------------------
#include <stdio.h>
class testClass1 {};
class testClass2 {
public:
testClass2():i(0) {}
testClass2(const testClass2 &t)
{
i = t.i;
}
void fun();
private:
int i;
};
class testClass3:public testClass2 {
public:
testClass3():j(0) {}
testClass3(const testClass3 &t)
{
j = t.j;
}
private:
int j;
};
int main()
{
testClass1 t1;
testClass2 t2;
printf("sizeof testClass1 = %d\n", sizeof(testClass1));
printf("sizeof t1 = %d\n", sizeof(t1));
printf("sizeof testClass2 = %d\n", sizeof(testClass2));
printf("sizeof t2 = %d\n", sizeof(t2));
printf("sizeof int = %d\n", sizeof(int));
//testClass2 t2;
//testClass3 t3;
//t2 = t3;
//t3 = t2;//error
}
$ g++ -o test1 test1.cpp
$ ./test1
sizeof testClass1 = 1
sizeof t1 = 1
sizeof testClass2 = 4
sizeof t2 = 4
sizeof int = 4