#include <iostream>

using namespace std;

struct A
{
  int x;
  A(int x) : x(x) {}
};

struct B : A
{
  B() : A(7) {}
  // int y; // if uncomment, program vouldn't compile
};

static_assert(sizeof (A) == sizeof (B), "B must have same size as A");

int main()
{
  A *a = new B[4];
  
  for (size_t q=0; q<4; ++q)
    cout << q << ": " << a[q].x << endl;
  
  delete [] a;
  
  return 0;
}