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

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

    the reason for class with no data members but having size 1 byte is that the this*strong text* must be stored in memory so that a reference or pointer can point to the object of that class

提交回复
热议问题