what is the size of empty class in C++,java?
问题 What is the size of an empty class in C++ and Java? Why is it not zero? sizeof(); returns 1 in the case of C++. 回答1: Short Answer: The standard explicitly says that a class can not have zero size. Long Answer: Because each object needs to have a unique address (also defined in the standard) you can't really have zero sized objects. Imagine an array of zero sized objects. Because they have zero size they would all line up on the same address location. So it is easier to say that objects can