Why addresses of two different objects should be different?

前端 未结 5 1267
予麋鹿
予麋鹿 2021-01-12 03:41

I\'ve been reading about this stuff that size of an object should be at least 1 byte (C++: What is the size of an object of an empty class?) and what\'s wrong about having t

5条回答
  •  太阳男子
    2021-01-12 04:17

    Try an analogy.

    If you have two cars, and you try to have them occupy the same physical space, you'll have a crash.

    If you have two objects and you try to have them occupy the same memory space, you'll also have a crash.

提交回复
热议问题