First of all, on my system the following hold: sizeof(char) == 1
and sizeof(char*) == 4
.
So simply, when we calculate the total size of the class below:
class SampleClass { char c; char* c_ptr; };
we could say that sizeof(SampleClass) = 5
. HOWEVER, when we compile the code, we easily see that sizeof(SampleClass) = 8
.
So the question is "where is the problem with calculation?" :S
Language: C++ Compiler: gcc 4.4.0 OS: Tinycore