C++ | Inheritance | Question 3

Last Updated :
Discuss
Comments
Assume that an integer takes 4 bytes and there is no alignment in following classes, predict the output. C
#include<iostream>
using namespace std;

class base {
    int arr[10];
};

class b1: public base { };

class b2: public base { };

class derived: public b1, public b2 {};

int main(void)
{
  cout << sizeof(derived);
  return 0;
}
40
80
0
4
Share your thoughts in the comments