c++ sizeof() of a class with functions

后端 未结 7 904
情深已故
情深已故 2020-12-01 10:38

I have a C++ question. I wrote the following class:

class c
{
    int f(int x, int y){ return x; }
};

the sizeof() of class c returns \"1\"

7条回答
  •  醉梦人生
    2020-12-01 11:10

    It's size is of 1, because it can not be 0, otherwise two objects of this type wouldn't be addressable (couldn't differentiate their addresses)

提交回复
热议问题