sizeof not working
-
I wrote this code:
class ChessPiece
{};
int main()
{
cout << "size:" << sizeof(ChessPiece) << endl;
}For some reason, it prints out 1 instead of 0. Anyone know why? Thanks.
-
I wrote this code:
class ChessPiece
{};
int main()
{
cout << "size:" << sizeof(ChessPiece) << endl;
}For some reason, it prints out 1 instead of 0. Anyone know why? Thanks.
Perhaps take a look at this FAQ. Stroustrup: C++ Style and Technique FAQ[^]
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment "Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst "I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle
-
Perhaps take a look at this FAQ. Stroustrup: C++ Style and Technique FAQ[^]
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment "Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst "I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle
-
That is interesting. That page references a 'better' link. Same answer is there. Standard C++[^] Myself though if Stroustrop is the name then I would consider that better.
jschell wrote:
if Stroustrop is the name then I would consider that better.
Agreed. :)
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment "Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst "I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle