C++: What is the size of an object of an empty class?

后端 未结 16 1779
悲&欢浪女
悲&欢浪女 2020-11-22 11:54

I was wondering what could be the size of an object of an empty class. It surely could not be 0 bytes since it should be possible to reference and

16条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-22 12:36

    empty class -that class does not contain any content.

    any class which is not empty will be represented by its content in memory.

    now how empty class will be represented in memory? as it has no content no way to show its existance in memory, but class is present ,it is mandatory to show its presence in memory. To show empty class presence in memory 1 byte is required.

提交回复
热议问题