zhangyuanes / cpp-interviews-questions

2 stars 0 forks source link

【2021-字节实习二面】2. 代码分析 #12

Open zhangyuanes opened 3 years ago

zhangyuanes commented 3 years ago

因为你说你C++比较熟悉,那出一段代码给你分析一下,你看下结果是多少?(不能运行)

#include <iostream>
using namespace std;

class A {
    int a;
}

class B : public A {
    int b;
    static int c;
    int* d;
}

int main(){
    B b;
    cout << sizeof(b) << endl;
    return 0;
}