fork(3) download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. struct A
  6. {
  7. int x;
  8. A(int x) : x(x) {}
  9. };
  10.  
  11. struct B : A
  12. {
  13. B() : A(7) {}
  14. };
  15.  
  16. int main()
  17. {
  18. A *a = new B[4];
  19.  
  20. for (size_t q=0; q<4; ++q)
  21. cout << q << ": " << a[q].x << endl;
  22.  
  23. delete [] a;
  24.  
  25. return 0;
  26. }
Success #stdin #stdout 0s 4248KB
stdin
Standard input is empty
stdout
0: 7
1: 7
2: 7
3: 7