c++ sizeof() of a class with functions

后端 未结 7 916
情深已故
情深已故 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:14

    sizeof(char)==1 always, because a char is a byte and sizeof returns a number of bytes. (However, a byte is not necessarily exactly eight bits.)

    Absolutely true. Hence the term "octet" (to distinguish something that is exactly 8 bits from the more commonly used term "byte").

    For more info, look at IEEE 1541:

    http://en.wikipedia.org/wiki/IEEE_1541

提交回复
热议问题