I use c++ in linux which is gcc version 4.4.1 (Ubuntu 4.4.1-4ubuntu9).
I considered that c++ memory alignment is like the following:
|
|
vc++ use #pragma_pack(n) set the default.if there are three char in a struct, like:
|
|
|
|
|
|
if the class or struct is empty, sizeof(it) will be 1.
But if there are static varibles in classes or structs, you can remove it!. like:
|
|
in class there will be many class functions. But A class is thought as A struct and many functions set. sizeof(A class) will compute the size of struct.
|
|
but when we meet the virtual member functions and virtual derived class, it will be different.