sizeof *this object

后端 未结 3 1985
野性不改
野性不改 2021-02-19 10:39

Code:

#include 

class myc {
    int dummy;
public:
    int si(){return sizeof(*this);}
};

class d_myc : public myc {
    int d_dummy;
};

int mai         


        
3条回答
  •  -上瘾入骨i
    2021-02-19 11:21

    sizeof is resolved at compile-time, not run-time. So sizeof(*this) is equivalent to sizeof(myc).

提交回复
热议问题