bool test;
sizeof(test) = 1 if using VS 2010. Since every C++ data type must be addressable,
the \"test\" bool variable is 8-bits(1 byte).
My qu
My question is that does the "test" variable really occupy 1 byte in memory?
Yes, if sizeof(bool)==1 . Basically, the sizeof bool is implementation-defined, which means it could be greater than 1 byte for certain compiler.
bool test1[32](in VS 2010), int test2(in VS 2010)
Does test1 and test2 occupy the same memory?
What each of them occupy can be known by using sizeof operator. That is what sizeof operator is for. So test1 and test2 will occupy sizeof(test1) and sizeof(test2) bytes respectively.