Why does the size of a derived class include private members from the base class?

前端 未结 7 1858
谎友^
谎友^ 2021-02-09 19:52

I have the following code:

class A {
  private:
    int i;
 };

class B : public A {
 private:
  int j;
 };

When I check sizeof(B)

7条回答
提交回复
热议问题