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

后端 未结 16 1621
悲&欢浪女
悲&欢浪女 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:48

    I think that if the size of an empty class is zero it means that it does not exist. For it (class) to exist, it requires to have at least 1 byte, since this byte is the memory/reference address.

提交回复
热议问题