How do you determine the size of an object in C++?

前端 未结 11 985
轮回少年
轮回少年 2020-11-28 05:38

For example, say I have a class Temp:

class Temp
{
    public:
        int function1(int foo) { return 1; }
        void function2(int bar) { foobar = bar; }         


        
11条回答
  •  眼角桃花
    2020-11-28 06:26

    There's a utility call pahole (for 'Poke-A-HOLE') that's nominally intended to study how object layouts get padded, but is great for visualizing object size and layout in general.

提交回复
热议问题