0
sizeof an object
class A {} int main { A a; cout << sizeof(a); // outputs 1 Why is this the case? Are we evaluating the object name as a char?
2 Respostas
+ 8
Each object is given different address. So to distinguish different objects, size of each empty class object is 1 byte i.e. minimum memory allotted as per C++ standards.
Some useful answers, you can get here:
https://stackoverflow.com/questions/2362097/why-is-the-size-of-an-empty-class-in-c-not-zero
0
yes!